pub use std::cell::{RefCell, RefMut};
pub use std::rc::Rc;
+pub use index_vec::Idx;
+
type Setup = Rc<RefCell<SetupCore>>;
struct Ctx {
mod pi {
use otter::prelude::define_index_type;
- define_index_type!{ pub struct PI = usize; }
+ define_index_type!{ pub struct PIA = usize; }
+ define_index_type!{ pub struct PIB = usize; }
}
-pub use pi::PI;
+pub use pi::*;
#[derive(Debug,Clone)]
struct PieceInfo<I> {
impl Session {
#[throws(AE)]
- fn pieces(&self) -> IndexVec<PI, PieceInfo<JsV>> {
+ fn pieces<PI:Idx>(&self) -> IndexVec<PI, PieceInfo<JsV>> {
self.dom
.element("#pieces_marker")
.unwrap().next_siblings()
Some(EXIT_NOTFOUND));
let mut session = self.connect_player(&self.alice)?;
- let pieces = session.pieces()?;
+ let pieces = session.pieces::<PIA>()?;
dbg!(&pieces);
let llm = pieces.into_iter()
.filter(|pi| pi.info["desc"] == "a library load area marker")
let mut bob = self.connect_player(&self.bob)?;
self.su_mut().mgmt_conn.fakerng_load(&[&"1"])?;
- let a_pieces = alice.pieces()?;
+ let a_pieces = alice.pieces::<PIA>()?;
let [hand] = a_pieces.iter().enumerate()
.filter(|(i,p)| p.info["desc"] == otter::hand::UNCLAIMED_DESC)
"wrc": "Unpredictable",
}))?;
- fn find_pawns(pieces: &IndexSlice<PI,[PieceInfo<JsV>]>) -> [PI; 2] {
+ fn find_pawns<PI:Idx>(pieces: &IndexSlice<PI,[PieceInfo<JsV>]>)
+ -> [PI; 2]
+ {
let pawns = pieces.iter_enumerated()
.filter(|(i,p)| p.info["desc"].as_str().unwrap().ends_with(" pawn"))
.map(|(i,_)| i)