func (s *Source) NewPlanetView(fid int, pl overpower.PlanetDat, exodus bool) overpower.PlanetViewDat { pv := &PlanetView{ GID: s.GID, FID: fid, Loc: pl.Loc(), Name: pl.Name(), } if pl.PrimaryFaction() == fid || pl.SecondaryFaction() == fid { pv.Turn = 1 pF := pl.PrimaryFaction() sF := pl.SecondaryFaction() if pF != 0 { pv.PrimaryFaction = sql.NullInt64{Valid: true, Int64: int64(pF)} } if sF != 0 { pv.SecondaryFaction = sql.NullInt64{Valid: true, Int64: int64(sF)} } pv.PrimaryPresence = pl.PrimaryPresence() pv.PrimaryPower = pl.PrimaryPower() pv.SecondaryPresence = pl.SecondaryPresence() pv.SecondaryPower = pl.SecondaryPower() pv.Antimatter = pl.Antimatter() pv.Tachyons = pl.Tachyons() } s.M.CreatePlanetView(pv) return pv.Intf() }
func (s *Source) UpdatePlanetView(fid, turn int, planet overpower.PlanetDat) overpower.PlanetViewDat { pv := &PlanetView{ GID: s.GID, FID: fid, Turn: turn, // Name: planet.Name(), Loc: planet.Loc(), PrimaryPresence: planet.PrimaryPresence(), PrimaryPower: planet.PrimaryPower(), SecondaryPresence: planet.SecondaryPresence(), SecondaryPower: planet.SecondaryPower(), Antimatter: planet.Antimatter(), Tachyons: planet.Tachyons(), } pF := planet.PrimaryFaction() sF := planet.SecondaryFaction() if pF != 0 { pv.PrimaryFaction = sql.NullInt64{Valid: true, Int64: int64(pF)} } if sF != 0 { pv.SecondaryFaction = sql.NullInt64{Valid: true, Int64: int64(sF)} } pv.sql.UPDATE = true // pt := [3]int{pv.Loc[0], pv.Loc[1], fid} sess := s.M.PlanetView() if i, ok := s.updatedPVs[pt]; ok { sess.List[i] = pv } else { s.updatedPVs[pt] = len(sess.List) sess.List = append(sess.List, pv) } sess.List = append(sess.List, pv) return pv.Intf() }