10
10
import colorama
11
11
colorama .init ()
12
12
except ImportError :
13
+ click = None
14
+ requests = None
15
+ colorama = None
13
16
print ("Use as a command-line interface requires optional dependencies: click, requests and colorama" )
14
17
exit ()
15
18
@@ -106,6 +109,7 @@ def cli_world(name, tibiadata, json):
106
109
@click .option ("-td" , "--tibiadata" , default = False , is_flag = True )
107
110
@click .option ("-js" , "--json" , default = False , is_flag = True )
108
111
def cli_worlds (tibiadata , json ):
112
+ """Displays the list of worlds and their data."""
109
113
worlds = _fetch_and_parse (ListedWorld .get_list_url , ListedWorld .list_from_content ,
110
114
ListedWorld .get_list_url_tibiadata , ListedWorld .list_from_tibiadata ,
111
115
tibiadata )
@@ -116,18 +120,19 @@ def cli_worlds(tibiadata, json):
116
120
import json as _json
117
121
print (_json .dumps (worlds , default = ListedWorld ._try_dict , indent = 2 ))
118
122
return
119
- print (print_world_overview (worlds ))
123
+ print (print_world_list (worlds ))
120
124
121
125
122
126
@cli .command (name = "house" )
123
- @click .argument ('id ' )
127
+ @click .argument ('house_id ' )
124
128
@click .argument ('world' )
125
129
@click .option ("-td" , "--tibiadata" , default = False , is_flag = True )
126
130
@click .option ("-js" , "--json" , default = False , is_flag = True )
127
- def cli_house (id , world , tibiadata , json ):
131
+ def cli_house (house_id , world , tibiadata , json ):
132
+ """Displays information about a house."""
128
133
house = _fetch_and_parse (House .get_url , House .from_content ,
129
134
House .get_url_tibiadata , House .from_tibiadata ,
130
- tibiadata , id , world )
135
+ tibiadata , house_id , world )
131
136
if json and house :
132
137
print (house .to_json (indent = 2 ))
133
138
return
@@ -141,6 +146,7 @@ def cli_house(id, world, tibiadata, json):
141
146
@click .option ("-js" , "--json" , default = False , is_flag = True )
142
147
@click .option ("-gh" , "--guildhalls" , default = False , is_flag = True )
143
148
def cli_houses (world , town , tibiadata , json , guildhalls ):
149
+ """Displays the list of houses of a world."""
144
150
town = " " .join (town )
145
151
house_type = HouseType .GUILDHALL if guildhalls else HouseType .HOUSE
146
152
houses = _fetch_and_parse (ListedHouse .get_list_url , ListedHouse .list_from_content ,
@@ -221,7 +227,7 @@ def get_character_string(character: Character): # NOSONAR
221
227
content += build_header ("Other Characters" )
222
228
for other_char in character .other_characters :
223
229
content += "- %s - %s - %s\n " % (other_char .name , other_char .world , "online" if other_char .online else
224
- ("deleted" if other_char .deleted else "offline" ))
230
+ ("deleted" if other_char .deleted else "offline" ))
225
231
return content
226
232
227
233
@@ -311,14 +317,12 @@ def print_world(world: World):
311
317
return content
312
318
313
319
314
- def print_world_overview ( world_overview ):
320
+ def print_world_list ( world_list ):
315
321
content = build_header ("Game World Overview" , "=" )
316
- content += get_field ("Total online" , world_overview .total_online )
317
- content += get_field ("Overall Maximum" , "%d players on %s" % (world_overview .record_count ,
318
- world_overview .record_date ))
322
+ content += get_field ("Total online" , sum (w .online_count for w in world_list ))
319
323
320
324
content += build_header ("Worlds" )
321
- for world in world_overview . worlds :
325
+ for world in world_list :
322
326
content += "%s - %d Online - %s - %s\n " % (world .name , world .online_count , world .location , world .pvp_type )
323
327
return content
324
328
@@ -335,7 +339,7 @@ def get_house_string(house):
335
339
if house .status == "auctioned" :
336
340
content += get_field ("Highest bid" , "%d gold by %s, auction ends on %s" %
337
341
(house .highest_bid , house .highest_bidder , house .auction_end )
338
- if house .highest_bidder else "None" )
342
+ if house .highest_bidder else "None" )
339
343
else :
340
344
content += get_field ("Rented by" , "%s, paid until %s" % (house .owner , house .paid_until ))
341
345
if house .transfer_date :
0 commit comments