Exemplo n.º 1
0
def delete_equipments(request):
    '''装備を全て削除する'''

    db.delete(EquipmentClass.all(keys_only=True))
    db.delete(UpgradeClass.all(keys_only=True))

    context = {}

    return HttpResponseRedirect(reverse('admin.views.index'))
Exemplo n.º 2
0
def equipments(request):
    '''装備をすべて表示する'''

    equipments = []
    for i in EquipmentClass.all():
        equipments.append({
                'equipment': i,
                'upgrades': UpgradeClass.get_by_equipment(i)})
    context = {
        'items': equipments
        }
    return direct_to_template(request, 'equipments.html', context)
Exemplo n.º 3
0
    def _put_equipment_list(self, items):
        '''装備リストを解析した情報を保存する
        また、その装備を更新するための Source を追加する'''
        result = []
        for item in items:
            url = item.get('url')
            if not url:
                continue
            model = EquipmentClass.create_or_update(
                name=item['name'],
                source=url
                )
            result.append(model)

            source = Source(name=item['name'], type='weapon', url=url)
            source.put()
        return result
Exemplo n.º 4
0
    def _put_equipment(self, item):
        '''装備を解析した情報を保存する'''

        effects = []
        effects.append(Effect(param='range', min=item['range']))
        effects.append(Effect(param='attack_min', min=item['attack'][0]))
        effects.append(Effect(param='attack_max', min=item['attack'][1]))
        effects.append(Effect(param='durability', min=item['durability']))
        effects.append(Effect(param='wound_min', min=item['wound'][0]))
        effects.append(Effect(param='wound_max', min=item['wound'][1]))
        effects.append(Effect(param='critical', min=item['critical']))
        effects.append(Effect(param='balance', min=item['balance']))

        model = EquipmentClass.create_or_update(
            name = item['name'],
            effects = effects,
            category = item['category'],
            ug = item['ug'],
            )
            
        upgrades = [self._put_upgrade(u, model) for u in item['upgrades']]

        return model