This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better error handling, split some files
- Loading branch information
Arzaroth Lekva
committed
Dec 26, 2014
1 parent
87f4371
commit b56314f
Showing
7 changed files
with
150 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# File: set.py | ||
# by Arzaroth Lekva | ||
# [email protected] | ||
# | ||
|
||
def set_currency(xml_handle, args): | ||
for currency_id in args['<currency_id>']: | ||
for typ in xml_handle.currencies.values(): | ||
for val in typ.values(): | ||
if currency_id == val.name: | ||
try: | ||
val.value = args['<value>'] | ||
except ValueError as e: | ||
print(str(e)) | ||
|
||
def _process_set_pony(xml_handle, pony, args): | ||
if args['level']: | ||
if args['up']: | ||
pony.level_up() | ||
elif args['down']: | ||
pony.level_down() | ||
else: | ||
pony.level = args['<value>'] | ||
elif args['shards']: | ||
if args['up']: | ||
pony.shard_up() | ||
elif args['down']: | ||
pony.shard_down() | ||
else: | ||
pony.shards = args['<value>'] | ||
elif args['next_game']: | ||
try: | ||
pony.next_game = Pony.GameTypes.map[args['<value>']] | ||
except KeyError: | ||
raise ValueError("Invalid game type") | ||
elif args['reset_game_timer']: | ||
pony.reset_game_timer() | ||
|
||
def set_ponies(xml_handle, args): | ||
try: | ||
for pony in xml_handle.ponies.values(): | ||
_process_set_pony(xml_handle, pony, args) | ||
except Exception as e: | ||
print(str(e)) | ||
|
||
def set_pony(xml_handle, args): | ||
try: | ||
for pony_id in args['<pony_id>']: | ||
if pony_id in xml_handle.ponies: | ||
_process_set_pony(xml_handle, xml_handle.ponies[pony_id], args) | ||
except Exception as e: | ||
print(str(e)) | ||
|
||
def _process_set_zone(xml_handle, zone, args): | ||
if args['clearables']: | ||
zone.clear_clearable_items() | ||
elif args['foes']: | ||
zone.clear_foes() | ||
else: | ||
zone.clear_all() | ||
|
||
def set_zones(xml_handle, args): | ||
for zone in xml_handle.zones.values(): | ||
_process_set_zone(xml_handle, zone, args) | ||
|
||
def set_zone(xml_handle, args): | ||
for zone_id in args['<zone_id>']: | ||
if zone_id in xml_handle.zones: | ||
_process_set_zone(xml_handle, xml_handle.zones[zone_id], args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# File: show.py | ||
# by Arzaroth Lekva | ||
# [email protected] | ||
# | ||
|
||
def show_currencies(xml_handle, args): | ||
print('Main currencies:') | ||
for cur, val in xml_handle.currencies['Main'].items(): | ||
print(' {}: {}'.format(cur, val)) | ||
print('\nShards:') | ||
for cur, val in xml_handle.currencies['Shards'].items(): | ||
print(' {} shards: {}'.format(cur, val)) | ||
print('\nZecora ingredients:') | ||
for cur, val in xml_handle.currencies['Ingredients'].items(): | ||
print(' {}: {}'.format(cur, val)) | ||
|
||
def show_currency(xml_handle, args): | ||
for currency_id in args['<currency_id>']: | ||
for typ in xml_handle.currencies.values(): | ||
for val in typ.values(): | ||
if currency_id == val.name: | ||
print(val) | ||
return | ||
|
||
def show_ponies(xml_handle, args): | ||
print('Ponies:') | ||
for pony in xml_handle.ponies.values(): | ||
print(' {}'.format(pony)) | ||
if args['-i']: | ||
print('\nInventory ponies:') | ||
for pony in xml_handle.inventory_ponies.values(): | ||
print(' {}'.format(pony)) | ||
|
||
def show_pony(xml_handle, args): | ||
for pony_id in args['<pony_id>']: | ||
if pony_id in xml_handle.ponies: | ||
print(xml_handle.ponies[pony_id]) | ||
if pony_id in xml_handle.inventory_ponies: | ||
print(xml_handle.inventory_ponies[pony_id]) | ||
|
||
def show_zones(xml_handle, args): | ||
print('Zones:') | ||
for zone in xml_handle.zones.values(): | ||
print(' {}'.format(zone)) | ||
|
||
def show_zone(xml_handle, args): | ||
for zone_id in args['<zone_id>']: | ||
if zone_id in xml_handle.zones: | ||
print(xml_handle.zones[zone_id]) |