Using discord uuids as player ids and fixed issue with add_time
parent
935e0bb3f3
commit
5dd1b5daa7
|
@ -270,8 +270,6 @@ async fn add_time(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
||||||
|
|
||||||
let mut global_data = global_data.lock().await;
|
let mut global_data = global_data.lock().await;
|
||||||
|
|
||||||
global_data.game_state.next_phase();
|
|
||||||
|
|
||||||
let duration = match args.single::<u64>() {
|
let duration = match args.single::<u64>() {
|
||||||
Ok(d) => d,
|
Ok(d) => d,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -352,7 +350,7 @@ async fn vote(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
||||||
.game_state
|
.game_state
|
||||||
.get_player_from_channel_mut(msg.channel_id.0)
|
.get_player_from_channel_mut(msg.channel_id.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
player_data.vote_target = Some(target_player.channel);
|
player_data.vote_target = Some(target_player.discord_id);
|
||||||
|
|
||||||
vote_channel
|
vote_channel
|
||||||
.send_message(&ctx.http, |m| {
|
.send_message(&ctx.http, |m| {
|
||||||
|
|
|
@ -98,6 +98,10 @@ impl GameState {
|
||||||
self.player_data.iter().find(|p| p.channel == channel_id)
|
self.player_data.iter().find(|p| p.channel == channel_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_player_from_discord_id(&self, discord_id: u64) -> Option<&PlayerData> {
|
||||||
|
self.player_data.iter().find(|p| p.discord_id == discord_id)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_player_from_channel_mut(&mut self, channel_id: u64) -> Option<&mut PlayerData> {
|
pub fn get_player_from_channel_mut(&mut self, channel_id: u64) -> Option<&mut PlayerData> {
|
||||||
self.player_data
|
self.player_data
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
|
@ -141,7 +145,7 @@ impl GameState {
|
||||||
|
|
||||||
for player in &self.player_data {
|
for player in &self.player_data {
|
||||||
if let Some(vote_target) = player.vote_target {
|
if let Some(vote_target) = player.vote_target {
|
||||||
let target = self.get_player_from_channel(vote_target);
|
let target = self.get_player_from_discord_id(vote_target);
|
||||||
if let Some(target) = target {
|
if let Some(target) = target {
|
||||||
*vote_set.entry(target.codename.clone()).or_insert(0) += 1;
|
*vote_set.entry(target.codename.clone()).or_insert(0) += 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue