示例#1
0
 def victory(self):
     self.loc.owner = self.owner
     TradeRoute.autoconnect(self.loc)
     self.loc.structures[0].plan = plan("T")
     self.loc.structures[0].health = 100
     if self.get_builder():
         self.loc.structures[2].plan = plan("M")
         self.loc.structures[2].health = 100
     self.loc.storage[self.loc.active_solvent] = 500
     FleetBattle.all_.remove(self)
     del self
     print("victory")
示例#2
0
    def gametick(self):
        if self.owner is not None and all(s.plan == plan("") for s in self.structures):
            self.owner = None
        self.counter += 1

        self.storage += self.solvents
        for k in self.storage:
            if self.storage[k] > 9999:
                self.storage[k] = 9999
        for s in self.structures:
            s.gametick()
        if self.autofire and 1 == self.counter * sum((s.plan == plan("S") for s in self.structures)) % 360:
            for f in FleetFlying.all_:
                if f.target == self:
                    cost = {metal("I"): 80, metal("M"): 40, metal("G"): 20}
                    if all(v >= cost.get(k, 0) for k, v in self.storage.items()):
                        f.create_missile()
示例#3
0
 def check_lose(self):
     planets = chain(*(s.planets for s in Star.all_))
     if not any(p.owner == self and any(s.plan == plan("C") for s in p.structures) for p in planets):
         print(self.name, "lost")
         for p in planets:
             if p.owner == self:
                 p.owner = None
         Team.all_.remove(self)
         if self == Team.UI_base:
             print("ERROR deleting UI link")
示例#4
0
    def find_planet(self):
        for s in Star.all_:
            for p in s.planets:
                if p.active_solvent is not None and p.solvents[p.active_solvent] > 0.5 and p.owner is None:
                    p.owner = self
                    for s, l in zip(p.structures, "TCMLS"):
                        s.plan = plan(l)
                        s.health = 100

                    p.storage += {m: 5000 for m in metals()}

                    if Team.UI_base is self:
                        p.show()
                    return True
        return False
示例#5
0
    def perform_attack(self):
        # if self.loc.owner == None:
        #    self.victory()
        #    return

        if not any(self.ships.values()):
            self.defeat()
            return

        for s in self.loc.structures:
            s.health -= self.get_power()
            if s.plan == plan("S"):
                self.ships = FleetBattle.apply_damage(self.ships, 20)

        if all(s.plan == emptyplan for s in self.loc.structures):
            self.victory()
示例#6
0
 def perform(self):
     if self.plan == plan("L"):
         self.buildfleet(self)
示例#7
0
 def build(self, key):
     if not all(v >= plan(key).cost.get(k, 0) for k, v in self.parent.storage.items()):
         return
     self.plan = plan(key)
     self.parent.storage -= self.plan.cost
     self.health = 100 * (self.plan != emptyplan)
示例#8
0
 def can_trade(self):
     return any(s.plan == plan("T") for s in self.structures)