Example #1
0
    def MoveTo(self, tile):
        # check moves
        if self.Owner.Moves < 1:
            return
        # check turn
        if self.Owner != self._logic.PlayingPlayer:
            raise Exception("player is not on turn")
        # check if you move in the right area
        from GameLogic.Map import SeaTile
        if tile not in MapHelpers.getAroundingTiles(self.Tile, self._logic.Map):
            raise Exception("you are not aloud to move this unit more than one tile")
        elif tile.Unit is not None and tile.Unit.Owner != self.Owner:
            return
        # check for actions with the sea
        elif type(tile) is SeaTile:
            if tile.Unit is None:
                self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile
                self._tile = tile
                if self.Unit is not None:
                    self.Unit.Tile = tile
            else:
                return
        else:
            return

        self._logic.PlayingPlayer.Moves -= 1
Example #2
0
    def MoveTo(self, tile):
        # check moves
        if self.Owner.Moves < 1:
            return
        # check turn
        if self.Owner != self._logic.PlayingPlayer:
            raise Exception("player is not on turn")
        # check if you move in the right area
        from GameLogic.Map import SeaTile
        if tile not in MapHelpers.getAroundingTiles(self.Tile,
                                                    self._logic.Map):
            raise Exception(
                "you are not aloud to move this unit more than one tile")
        elif tile.Unit is not None and tile.Unit.Owner != self.Owner:
            return
        # check for actions with the sea
        elif type(tile) is SeaTile:
            if tile.Unit is None:
                self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile
                self._tile = tile
                if self.Unit is not None:
                    self.Unit.Tile = tile
            else:
                return
        else:
            return

        self._logic.PlayingPlayer.Moves -= 1
Example #3
0
def BuyBarrack(logic, tile, player):
    price = getBarackPrice(tile, player.Character)
    if price is None:
        return

    if price > player.Money:
        return
    # check if tile is empty
    if tile.Unit is None and tile.Building is None:
        if next((True for t in MapHelpers.getAroundingTiles(tile, logic.Map) if
                 t.Unit is not None and t.Unit.Owner == player), False):
            tile.Building = Barrack(tile, player)
            player.Money -= price
            player.Moves -= 1
            return tile.Building
Example #4
0
    def MoveTo(self, tile: Tile):
        # check moves
        if self.Owner.Moves < 1:
            return
        # check turn
        if self.Owner != self._logic.PlayingPlayer:
            raise Exception("player is not on turn")
        # check if you move in the right area
        from GameLogic.Map import SeaTile
        if tile not in MapHelpers.getAroundingTiles(self.Tile, self._logic.Map):
            return
        elif tile.Unit is not None and tile.Unit.Owner != self.Owner:  # fight
            if self.AttackPoints > tile.Unit.DefencePoints:
                tile.Unit.Die()
            else:
                return
        elif tile.Building is not None:
            if tile.Building.Owner == self.Owner:
                return None
            else:
                tile.Building.DefencePoints -= self.AttackPoints
                self.Die()
                if tile.Building.DefencePoints <= 0:
                    tile.Building = None
                self.Owner.Moves -= 1
                return

        # check for actions with the sea
        if type(tile) is SeaTile:
            # check if there is a boat available
            if tile.Unit is not None and type(tile.Unit) is Boat:
                # check if it is possible to place this unit in the boat
                boat = tile.Unit
                if boat.Unit is not None:
                    return
                else:
                    boat.Unit = self
                    self.Tile.Unit = None
                    self.Tile = tile
            else:
                return
        # no sea
        else:
            if tile.Unit is None:
                if self.Tile.Unit == self:
                    self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile
            elif type(tile.Unit) is UnitGroup:
                unitGroup = tile.Unit
                if unitGroup.CountUnits < 4:
                    if self.Tile.Unit == self:
                        self.Tile.Unit = None
                    self.Tile = tile
                    unitGroup.AddUnit(self)
                else:
                    return
            elif isinstance(tile.Unit, Unit):
                group = UnitGroup(tile, self.Owner, self._logic)
                self.Tile.Unit = None
                self.Tile = tile
                group.AddUnit(self)
                group.AddUnit(tile.Unit)
                tile.Unit = group

        self._logic.PlayingPlayer.Moves -= 1
Example #5
0
    def MoveTo(self, tile):
        # check moves
        if self.Owner.Moves < 1:
            return
        # check turn
        if self.Owner != self._logic.PlayingPlayer:
            if self.AttackPoints > tile.Unit.DefencePoints:
                tile.Unit.Die()
            else:
                return
        # check if you move in the right area
        from GameLogic.Map import SeaTile
        if tile not in MapHelpers.getAroundingTiles(self.Tile, self._logic.Map):
            raise Exception("You are not allowed to move this unit more than one tile")
        elif tile.Unit is not None and tile.Unit.Owner != self.Owner:  # fight
            if self.AttackPoints == tile.Unit.DefencePoints:
                tile.Unit.Die()
                self.Die()
            elif self.AttackPoints > tile.Unit.DefencePoints:
                tile.Unit.Die()
            else:
                return
        if tile.Building is not None:
            if tile.Building.Owner == self.Owner:
                return None
            else:
                tile.Building.DefencePoints -= self.AttackPoints
                self.Die()
                if tile.Building.DefencePoints <= 0:
                    tile.Building = None
        # check for actions with the sea
        elif type(tile) is SeaTile:
            # check if there is a boat available
            if tile.Unit is not None and type(tile.Unit) is Boat:
                # check if it is possible to place this unit in the boat
                boat = tile.Unit
                if boat.Unit is not None:
                    return
                else:
                    boat.Unit = self
                    self.Tile.Unit = None
                    self.Tile = tile

        # no sea
        else:
            if tile.Unit is None:
                if self.Tile.Unit == self:
                    self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile
            elif type(tile.Unit) is not UnitGroup and self.CountUnits < 4:
                self.AddUnit(tile.Unit)
                if self.Tile.Unit == self:
                    self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile

            elif type(tile.Unit) is UnitGroup:
                return

        self._logic.PlayingPlayer.Moves -= 1
Example #6
0
    def MoveTo(self, tile: Tile):
        # check moves
        if self.Owner.Moves < 1:
            return
        # check turn
        if self.Owner != self._logic.PlayingPlayer:
            raise Exception("player is not on turn")
        # check if you move in the right area
        from GameLogic.Map import SeaTile
        if tile not in MapHelpers.getAroundingTiles(self.Tile,
                                                    self._logic.Map):
            return
        elif tile.Unit is not None and tile.Unit.Owner != self.Owner:  # fight
            if self.AttackPoints > tile.Unit.DefencePoints:
                tile.Unit.Die()
            else:
                return
        elif tile.Building is not None:
            if tile.Building.Owner == self.Owner:
                return None
            else:
                tile.Building.DefencePoints -= self.AttackPoints
                self.Die()
                if tile.Building.DefencePoints <= 0:
                    tile.Building = None
                self.Owner.Moves -= 1
                return

        # check for actions with the sea
        if type(tile) is SeaTile:
            # check if there is a boat available
            if tile.Unit is not None and type(tile.Unit) is Boat:
                # check if it is possible to place this unit in the boat
                boat = tile.Unit
                if boat.Unit is not None:
                    return
                else:
                    boat.Unit = self
                    self.Tile.Unit = None
                    self.Tile = tile
            else:
                return
        # no sea
        else:
            if tile.Unit is None:
                if self.Tile.Unit == self:
                    self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile
            elif type(tile.Unit) is UnitGroup:
                unitGroup = tile.Unit
                if unitGroup.CountUnits < 4:
                    if self.Tile.Unit == self:
                        self.Tile.Unit = None
                    self.Tile = tile
                    unitGroup.AddUnit(self)
                else:
                    return
            elif isinstance(tile.Unit, Unit):
                group = UnitGroup(tile, self.Owner, self._logic)
                self.Tile.Unit = None
                self.Tile = tile
                group.AddUnit(self)
                group.AddUnit(tile.Unit)
                tile.Unit = group

        self._logic.PlayingPlayer.Moves -= 1
Example #7
0
    def MoveTo(self, tile):
        # check moves
        if self.Owner.Moves < 1:
            return
        # check turn
        if self.Owner != self._logic.PlayingPlayer:
            if self.AttackPoints > tile.Unit.DefencePoints:
                tile.Unit.Die()
            else:
                return
        # check if you move in the right area
        from GameLogic.Map import SeaTile
        if tile not in MapHelpers.getAroundingTiles(self.Tile,
                                                    self._logic.Map):
            raise Exception(
                "You are not allowed to move this unit more than one tile")
        elif tile.Unit is not None and tile.Unit.Owner != self.Owner:  # fight
            if self.AttackPoints == tile.Unit.DefencePoints:
                tile.Unit.Die()
                self.Die()
            elif self.AttackPoints > tile.Unit.DefencePoints:
                tile.Unit.Die()
            else:
                return
        if tile.Building is not None:
            if tile.Building.Owner == self.Owner:
                return None
            else:
                tile.Building.DefencePoints -= self.AttackPoints
                self.Die()
                if tile.Building.DefencePoints <= 0:
                    tile.Building = None
        # check for actions with the sea
        elif type(tile) is SeaTile:
            # check if there is a boat available
            if tile.Unit is not None and type(tile.Unit) is Boat:
                # check if it is possible to place this unit in the boat
                boat = tile.Unit
                if boat.Unit is not None:
                    return
                else:
                    boat.Unit = self
                    self.Tile.Unit = None
                    self.Tile = tile

        # no sea
        else:
            if tile.Unit is None:
                if self.Tile.Unit == self:
                    self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile
            elif type(tile.Unit) is not UnitGroup and self.CountUnits < 4:
                self.AddUnit(tile.Unit)
                if self.Tile.Unit == self:
                    self.Tile.Unit = None
                tile.Unit = self
                self.Tile = tile

            elif type(tile.Unit) is UnitGroup:
                return

        self._logic.PlayingPlayer.Moves -= 1