pub struct StaticUserSetup {
pub nick: &'static str,
pub url: String,
+ pub player: PlayerId,
}
impl DirSubst {
#[throws(AE)]
- pub fn setup_static_users(&self, layout: PresentationLayout)
+ pub fn setup_static_users(&self, mgmt_conn: &mut MgmtChannelForGame,
+ layout: PresentationLayout)
-> Vec<StaticUserSetup>
{
#[throws(AE)]
- fn mk(su: &DirSubst, layout: PresentationLayout, u: StaticUser)
+ fn mk(su: &DirSubst, mgmt_conn: &mut MgmtChannelForGame,
+ layout: PresentationLayout, u: StaticUser)
-> StaticUserSetup
{
let nick: &str = u.into();
--account server:@nick@ \
--fixed-token @token@ \
join-game @table@")?)?;
+
+ let player = mgmt_conn.has_player(
+ &subst.subst("server:@nick@")?.parse()?
+ )?.unwrap().0;
+
let url = subst.subst("@url@/@pl@?@token@")?;
- StaticUserSetup { nick, url }
+ StaticUserSetup { nick, url, player }
}
StaticUser::iter().map(
|u| (||{
- let ssu = mk(self, layout, u).context("create")?;
+ let ssu = mk(self, mgmt_conn, layout, u).context("create")?;
Ok::<_,AE>(ssu)
})()
.with_context(|| format!("{:?}", u))
&mut |_|false
)?;
let spec = su.ds.game_spec_data()?;
+ let mut mc = su.mgmt_conn();
let [alice, bob]: [Player; 2] =
- su.ds.setup_static_users(default())?
+ su.ds.setup_static_users(&mut mc, default())?
.into_iter().map(|sus| Player { nick: sus.nick, url: sus.url })
.collect::<ArrayVec<_>>().into_inner().unwrap();
+ drop(mc);
let su_rc = Rc::new(RefCell::new(su));
tests(Ctx { opts, spec, su_rc, alice, bob })?;
#[derive(Debug)]
pub struct Window {
pub name: String,
+ pub player: PlayerId,
pub instance: InstanceName,
}
impl Setup {
#[throws(AE)]
- pub fn new_window<'s>(&'s mut self, instance: &Instance, name: &str)
+ pub fn new_window<'s>(&'s mut self, instance: &Instance, name: &str,
+ player: PlayerId)
-> Window {
let name = check_window_name_sanity(name)?;
let window = (||{
Ok::<_,AE>(Window {
name: name.to_owned(),
instance: instance.0.clone(),
+ player,
})
})()
.with_context(|| name.to_owned())
let w = Window {
name: name.clone(),
instance: TABLE.parse().context(TABLE)?,
+ player: default(),
};
self.w(&w)?.screenshot("final", log::Level::Info)
.context(name)
impl Setup {
#[throws(AE)]
pub fn setup_static_users(&mut self, instance: &Instance) -> Vec<Window> {
- self.core.ds.clone()
- .setup_static_users(self.opts.layout)?
+ let susus = self.core.ds.clone()
+ .setup_static_users(&mut self.mgmt_conn(), self.opts.layout)?;
+ susus
.into_iter().map(|sus|
{
- let w = self.new_window(instance, sus.nick)?;
+ let w = self.new_window(instance, sus.nick, sus.player)?;
self.w(&w)?.get(sus.url)?;
self.w(&w)?.screenshot("initial", log::Level::Trace)?;
Ok::<_,AE>(w)