Exemplo n.º 1
0
Arquivo: tiles.py Projeto: pvh/thegrid
def add_house(grid, coord, player):
    new_tlim = int(player['tlim']) + 4
    if new_tlim > int(grid['tlim']):
        new_tlim = int(grid['tlim'])
    
    player['tlim'] = new_tlim
    UpdateManager.sendClient(player.getUser(), "setTerritory", tlim = player['tlim'], tused = player['tused'])
    return True
Exemplo n.º 2
0
Arquivo: tiles.py Projeto: pvh/thegrid
def dest_miner(grid, coord, player):
    mines = grid.inRangeOf(coord, 99, 1)
    if mines == 0:
        return
    
    income = mines * 5
    total = player.addIncome(-income)

    UpdateManager.sendClient(player.getUser(), "setInc", inc = total)
Exemplo n.º 3
0
def payDay():
    for grid in Grid.all():
        for u in grid.getPlayers():
            inc = int(u['inc'])
            last = time() - float(u['lastInc'])
            if not u.getUser()['active']:
                continue
            
            # Check their interval
            if inc == 0:
                continue
            if inc * 100 < int(u['cash']):
                continue
            if last < math.log(inc) / 2:
                continue
            u.addCash(inc)
            u['lastInc'] = time()
            UpdateManager.sendClient(u.getUser(), "setCash", cash = u['cash'])
Exemplo n.º 4
0
Arquivo: async.py Projeto: pvh/thegrid
    # If it's not placeable
    if placeable is False:
        return { "status": 412, "coord": coord, "error": "invalid placement" }

    # Make sure they have enough cash for it
    if int(player['cash']) < props['price']:
        return { "status": 412, "coord": coord, "error": "not enough cash" }

    # Make sure they have enough territory
    if tile == 1 and int(player['tused']) >= int(player['tlim']):
        return { "status": 412, "coord": coord, "error": "territory limit" }
    elif tile == 1:
        player['tused'] = int(player['tused']) + 1
        UpdateManager.sendClient(handler.user, "setTerritory", 
            tused = player['tused'],
            tlim = player['tlim']
        )

    # Subtract the cash
    player.addCash(-props['price'])
    UpdateManager.sendClient(handler.user, "setCash", cash = player['cash'])

    c['type'] = tile
    c['player'] = handler.user['pid']
    c['health'] = props['health']

    UpdateManager.sendCoord(g, c, handler.user)

    return { "status": 200 }

def sendMessage(handler, **args):
Exemplo n.º 5
0
Arquivo: tiles.py Projeto: pvh/thegrid
def dest_territory(grid, coord, player):
    new_tused = int(player['tused']) - 1
    player['tused'] = new_tused
    UpdateManager.sendClient(player.getUser(), "setTerritory", tlim = player['tlim'], tused = new_tused)
Exemplo n.º 6
0
Arquivo: tiles.py Projeto: pvh/thegrid
def dest_house(grid, coord, player):
    new_tlim = int(player['tlim']) - 4

    player['tlim'] = new_tlim
    UpdateManager.sendClient(player.getUser(), "setTerritory", tlim = player['tlim'], tused = player['tused'])