Exemplo n.º 1
0
func (s *Source) NewLaunchRecord(turn int, o overpower.LaunchOrderDat, ship overpower.ShipDat) {
	lr := &LaunchRecord{
		GID:       s.GID,
		FID:       o.FID(),
		Turn:      turn,
		Source:    o.Source(),
		Target:    o.Target(),
		OrderSize: o.Size(),
	}
	if ship != nil {
		lr.Size = ship.Size()
	}
	s.M.CreateLaunchRecord(lr)
}
Exemplo n.º 2
0
func (s *Source) NewBattleRecord(ship overpower.ShipDat, fid, turn,
	initPrimaryFac, initPrPres,
	initSecondaryFac, initSePres int,
	result overpower.PlanetDat,
	betrayals [][2]int,
) {
	btr := make([]int, 0, len(betrayals)*2)
	for _, pt := range betrayals {
		btr = append(btr, pt[0], pt[1])
	}

	br := &BattleRecord{
		GID:       s.GID,
		FID:       fid,
		Turn:      turn,
		Loc:       result.Loc(),
		Betrayals: btr,

		InitPrimaryPresence:   initPrPres,
		InitSecondaryPresence: initSePres,
		PrimaryPresence:       result.PrimaryPresence(),
		SecondaryPresence:     result.SecondaryPresence(),
	}
	if ship != nil {
		br.ShipFaction = sql.NullInt64{Valid: true, Int64: int64(ship.FID())}
		br.ShipSize = ship.Size()
	}
	if initPrimaryFac != 0 {
		br.InitPrimaryFaction = sql.NullInt64{Valid: true, Int64: int64(initPrimaryFac)}
	}
	if initSecondaryFac != 0 {
		br.InitSecondaryFaction = sql.NullInt64{Valid: true, Int64: int64(initSecondaryFac)}
	}

	if resPrFac := result.PrimaryFaction(); resPrFac != 0 {
		br.PrimaryFaction = sql.NullInt64{Valid: true, Int64: int64(resPrFac)}
	}
	if resSeFac := result.SecondaryFaction(); resSeFac != 0 {
		br.SecondaryFaction = sql.NullInt64{Valid: true, Int64: int64(resSeFac)}
	}

	s.M.CreateBattleRecord(br)
}
Exemplo n.º 3
0
func (s *Source) NewShipView(sh overpower.ShipDat, fid, turn int, loc, dest hexagon.NullCoord, trail hexagon.CoordList) overpower.ShipViewDat {
	sv := &ShipView{
		GID:        s.GID,
		FID:        fid,
		Turn:       turn,
		Loc:        loc,
		Dest:       dest,
		Trail:      trail,
		Controller: sh.FID(),
		SID:        sh.SID(),
		Size:       sh.Size(),
	}
	s.M.CreateShipView(sv)
	return sv.Intf()
}