Changeset 21172

Show
Ignore:
Timestamp:
10/12/08 16:23:41 (3 months ago)
Author:
nishio
Message:

/lang/python/saichugen remove iround&iturn(refactoring)

Location:
lang/python/saichugen/gae
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/python/saichugen/gae/saichugen/main/logic.py

    r21155 r21172  
    5757def to_num(card): 
    5858    return card / 4 + 1 
     59 
  • lang/python/saichugen/gae/saichugen/main/models.py

    r21165 r21172  
    99    is_single_game = db.BooleanProperty(default=True) 
    1010 
     11    step = db.IntegerProperty(default=0) # 0..14 
     12    def next_step(self): 
     13        self.step += 1 
     14    def get_round(self): 
     15        return self.step / 3 
     16    def get_turn(self): 
     17        return self.step % 3 
     18 
    1119    def update(self, info): 
    1220        import cPickle 
  • lang/python/saichugen/gae/saichugen/main/views.py

    r21171 r21172  
    2424    #info = req.GET.get("info") 
    2525    info = dict( 
    26         iturn = 0, 
    27         iround = 0, 
    2826        game_score = [0, 0, 0], 
    2927        round_score = [0, 0, 0], 
     
    5957    plays = info["plays"] 
    6058    for i, xs in enumerate(plays): 
    61         cur_round = (i >= info["iround"] * 3) 
     59        cur_round = (i >= game.get_round() * 3) 
    6260        for p in range(3): 
    6361            if (info["winner_of_turn"][i] == p and 
     
    7068     
    7169    real_log = [[], [], []] 
    72     for i in range(info["iround"]): 
     70    for i in range(game.get_round()): 
    7371        for p in range(3): 
    7472            real_log[p].append(log[p][i * 3:i * 3 + 3]) 
    7573 
    7674    for p in range(3): 
    77         real_log[p].append(log[p][info["iround"] * 3:]) 
     75        real_log[p].append(log[p][game.get_round() * 3:]) 
    7876 
    7977    tvalue["real_log"] = real_log 
     
    108106        time_log.append(msg) 
    109107    tvalue["time_log"] = time_log 
    110     for key in "iround iturn game_score round_score".split(): 
     108    for key in "game_score round_score".split(): 
    111109        tvalue[key] = info[key] 
    112110 
     
    144142        info["round_score"][winner] += logic.to_num(mid) 
    145143        addTimeLog(info, "System", "END_TURN_",  
    146                    (info["iturn"], info["iturn"] + info["iround"] * 3)) 
    147         info["iturn"] += 1 
     144                   (game.get_turn(), game.step)) 
     145        game.next_step() 
    148146 
    149147        # もしターンIDが3ならラウンド終了処理 
    150         if info["iturn"] == 3: 
    151             info["iturn"] = 0 
     148        if game.get_turn() == 0: 
    152149            rs = info["round_score"] 
    153150            mid = logic.get_mid(rs) 
     
    160157                    winner.append(False) 
    161158            info["winner_of_round"].append(winner) 
    162             addTimeLog(info, "System", "END_ROUND", info["iround"]) 
     159            addTimeLog(info, "System", "END_ROUND", game.get_round()) 
    163160            info["round_score"] = [0, 0, 0] 
    164             info["iround"] += 1  
    165             if info["iround"] < 5: 
    166                 addTimeLog(info, "System", "START_ROUND", info["iround"]) 
     161            if game.get_round() < 5: 
     162                addTimeLog(info, "System", "START_ROUND", game.get_round()) 
    167163        # もしラウンドIDが5ならゲーム終了処理 
    168         if info["iround"] == 5: 
     164        if game.step == 15: 
    169165            game.is_finished = True 
    170             addTimeLog(game, "System", "END_GAME") 
     166            addTimeLog(info, "System", "END_GAME") 
    171167 
    172168        game.update(info) 
  • lang/python/saichugen/gae/template/game.html

    r21165 r21172  
    1111{% endif %} 
    1212<hr> 
    13 Round {{ iround|add:1 }}, turn {{ iturn|add:1 }}. 
     13Round {{ game.get_round|add:1 }}, turn {{ game.get_turn|add:1 }}. 
    1414Choose a card from your hand: 
    1515<p> 
     
    2323 
    2424<hr> 
     25盤面状況: 
    2526{% for logi in real_log %} 
    2627<div style="width:150px; float: left;">