Exemplo n.º 1
0
 def check_credit_payoff(self) -> int:
     current_month = db_connector.get_game_pid(self.id).turn_num
     result = 0
     for credit in db_connector.get_credits(self.id):
         if credit[3] == current_month - 12:
             self.pay_credit(credit[0], credit[3])
             result += credit[3]
Exemplo n.º 2
0
 def take_credit(self, amount: int) -> int:
     db_connector.set_money(self.player_id, self.money + amount)
     max_amount: int = self.fabrics_1 * 2500 + self.fabrics_2 * 5000
     already_taken: int = 0
     for credit in db_connector.get_credits(self.player_id):
         already_taken += credit[2]
     if already_taken < max_amount:
         max_amount -= already_taken
         if amount > max_amount:
             amount = max_amount
         db_connector.get_credits(self.player_id)
         db_connector.take_credit(
             self.player_id, amount,
             db_connector.get_game_pid(self.player_id).turn_num)
         return amount
     return 0
Exemplo n.º 3
0
 def get_score_list(self) -> list:
     result: list = []
     for ps in db_connector.get_player_state_gid(self.id):
         sum = ps.fabrics_1 * 5000 + ps.fabrics_2 * 10000 + ps.esm * self.market[self.market_lvl - 1][2] + \
               ps.egp * self.market[self.market_lvl - 1][4]
         for credit in db_connector.get_credits(ps.player_id):
             sum -= credit[2]
         sum += ps.money
         result.append([ps.player_id, sum])
     return self.sort_results(result)
Exemplo n.º 4
0
 def pay_bank_percent(self) -> list:
     # получить из бд по каждому игроку игры сумму ссуд и получить 1%
     ps: list = db_connector.get_player_state_gid(self.id)
     result: list = []
     for state in ps:
         sum: int = 0
         for credit in db_connector.get_credits(state.player_id):
             sum += credit[2]
         result.append((state.player_id, int(sum / 100)))
         db_connector.set_money(state.player_id,
                                state.money - int(sum / 100))
     return result
Exemplo n.º 5
0
import db_connector

if __name__ == '__main__':
    print(db_connector.get_credits(5))