insns
}
-
-
-/*
-
- let (_, nick2id) = chan.get_info()?;
-
- #[derive(Default)]
- struct St { id: PlayerId, old: bool, new: bool };
-
- let mut nick2st : HashMap<_,_> = {nick2id}
- .drain()
- .map(|(nick,id)| (nick, St { id, old: true, new: false }))
- .collect();
-
- for pspec in &spec.players {
- let nick = pspec.nick.unwrap_or_else(|| pspec.account.default_nick());
- let st = nick2st.entry(nick.clone()).or_default();
- if st.new {
- Err(anyhow!("duplicate player nick {:?} in spec", &nick))?;
- }
- st.new = true;
- let timezone = pspec.timezone.as_ref().or(
- spec.timezone.as_ref()
- ).cloned();
- // ^ todo use client program timezone?
- if !st.old {
- insns.push(MgmtGameInstruction::AddPlayer {
- account: pspec.account.clone(),
- details: MgmtPlayerDetails {
- nick: Some(nick),
- timezone,
- },
- });
- }
- }
-
- for (nick, st) in nick2st {
- if st.new { continue }
- if !st.old { continue }
- if ma.verbose >= 1 {
- eprintln!("removing old player {:?}", &nick);
- }
- insns.push(MGI::RemovePlayer { player: st.id });
- }
-
- let mut added_players = vec![];
- chan.alter_game(insns, Some(&mut |response| {
- match response {
- &Resp::AddPlayer { info, player, token } => {
- added_players.push((info.clone(), token.clone()));
- },
- _ => { },
- };
- Ok(())
- }))?;
-
- // report any new access tokens
- for (info, token) in added_players {
-
- access.deliver_tokens(&pspec, &ptokens)
- .with_context(||format!("deliver tokens for nick={:?}",
- &pspec.nick))?;
- }
- }
-*/
-
trait SomeSpec {
const WHAT : &'static str;
const FNCOMP : &'static str;