Esempio n. 1
0
func setPhase(t *testing.T, sp **state.State, match []string) {
	year, err := strconv.Atoi(match[1])
	if err != nil {
		t.Fatalf("%v", err)
	}
	season := match[2]
	typ := match[3]
	s := *sp
	for (s.Phase().Year() <= year && (string(s.Phase().Season()) != season || string(s.Phase().Type()) != typ)) || s.Phase().Year() != year {
		s.Next()
		newS := classical.Blank(s.Phase())
		a, b, c, d, e, _ := s.Dump()
		newS.Load(a, b, c, d, e, map[dip.Province]dip.Adjudicator{})
		*sp = newS
	}
	if s.Phase().Year() > year {
		t.Fatalf("What the, we wanted %v but ended up with %v", match, s.Phase())
	}
}
Esempio n. 2
0
func (self *Phase) State() (result *state.State, err error) {
	parsedOrders, err := orders.ParseAll(self.Orders)
	if err != nil {
		return
	}
	units := map[dip.Province]dip.Unit{}
	for prov, unit := range self.Units {
		units[prov] = unit
	}
	orders := map[dip.Nation]map[dip.Province][]string{}
	for nat, ord := range self.Orders {
		orders[nat] = ord
	}
	supplyCenters := map[dip.Province]dip.Nation{}
	for prov, nat := range self.SupplyCenters {
		supplyCenters[prov] = nat
	}
	dislodgeds := map[dip.Province]dip.Unit{}
	for prov, unit := range self.Dislodgeds {
		dislodgeds[prov] = unit
	}
	dislodgers := map[dip.Province]dip.Province{}
	for k, v := range self.Dislodgers {
		dislodgers[k] = v
	}
	bounces := map[dip.Province]map[dip.Province]bool{}
	for prov, b := range self.Bounces {
		bounces[prov] = b
	}
	result = classical.Blank(classical.Phase(
		self.Year,
		self.Season,
		self.Type,
	)).Load(
		units,
		supplyCenters,
		dislodgeds,
		dislodgers,
		bounces,
		parsedOrders,
	)
	return
}
Esempio n. 3
0
func init() {
	for _, variant := range OrderedVariants {
		Variants[variant.Name] = variant
	}
}

var Variants = map[string]Variant{}

var OrderedVariants = []Variant{
	Variant{
		Name:  Classical,
		Start: classical.Start,
		Blank: classical.Blank,
		BlankStart: func() (result *state.State, err error) {
			result = classical.Blank(classical.Phase(1900, cla.Fall, cla.Adjustment))
			return
		},
		ParseOrders: orders.ParseAll,
		ParseOrder:  orders.Parse,
		Graph:       start.Graph(),
		Phase:       classical.Phase,
		OrderTypes:  orders.OrderTypes(),
		Nations:     cla.Nations,
		PhaseTypes:  cla.PhaseTypes,
		Seasons:     cla.Seasons,
		UnitTypes:   cla.UnitTypes,
	},
	Variant{
		Name:  FleetRome,
		Graph: start.Graph(),