3
3
##-- Waste Land --##
4
4
5
5
##-- Import Modules --##
6
- import cmd
7
6
import os
8
7
import random
9
8
import sys
10
- import textwrap
11
9
import time
12
10
13
11
14
12
##-- Custom Imports --##
15
13
from Map_Gen import Engine
16
14
from Map_Gen import Biome
17
- from script import InfoDics , Items , Map , Mobs , NPC , Screen , Story
15
+ from script .Character import *
16
+ from script import InfoDics , Items , Screen , Story
18
17
19
18
import ChangeLog
20
19
21
- ##-- Globel Varibles --##
20
+ ##-- Global Variables --##
22
21
player_name = 'X' ##-- This is for the Funtion char_creation() --##
23
22
player_class_choice = 'X' ##-- This is also for the Funtion char_creation() --##
24
- player_in_game = 'X' ##-- Again this is also for the Funtion char_creation() --##
25
- mob = 'X' ##-- This varible is to hold the current mob player is fighing --##
23
+ player_in_game = None ##-- Again this is also for the Funtion char_creation() --##
26
24
gender = 'X' ##-- This varible sets the pronouns for the story and is set in the function in char_creation() in gender_call() --##
27
25
opening = True ##-- Only True if hasnt seen opening story --##
28
26
turn = True ##-- If True it's the players turn --##
@@ -53,75 +51,7 @@ def pause():
53
51
54
52
input ("Press Enter To Continue:> " )
55
53
56
- ##-- Inventory layout --##
57
54
58
- class PlayerInventory :
59
-
60
- def __init__ (self ):
61
-
62
- self .inventory_item_limit = 10
63
- self .bag = []
64
- self .equiped_weapon = Items .fist
65
- self .equiped_armor = Items .farm_clothing
66
-
67
- ##-- Below code is not in use and will change one I start using it --##
68
- def add_to_inventory (self , add_item ):
69
-
70
- self .add_item = add_item
71
- if len (self .bag ) < self .inventory_item_limit :
72
- self .bag .append (self .add_item )
73
-
74
- def remove_from_inv (self , remove_item ):
75
-
76
- self .remove_item = remove_item
77
-
78
- def hand_swap (self , requested_item ):
79
-
80
- self .requested_item = requested_item
81
-
82
- ##-- Player Inventory __init__ Call --##
83
-
84
- player_inventory = PlayerInventory ()
85
-
86
- ##-- Setting up player classes --##
87
- ##-- The player class handles all the players stat creation --##
88
- ##-- The Mage, Warrior, Archer and Assassin classes will inherit the Player class --##
89
- class Player :
90
-
91
- def __init__ (self , name , player_class , max_health , melee_attack , magic_attack ,
92
- max_mana , max_stamina , defense , pures , luck ):
93
-
94
- self .name = name
95
- self .player_class = player_class
96
- self .level = 1
97
- self .exp = 0
98
- self .max_health = max_health
99
- self .health = self .max_health ##-- Not sure if this is smart but this should only set health to max on making the character --##
100
- self .melee_attack = melee_attack
101
- self .magic_attack = magic_attack
102
- self .max_mana = max_mana
103
- self .mana = self .max_mana
104
- self .max_stamina = max_stamina
105
- self .stamina = self .max_stamina
106
- self .defense = defense
107
- self .pures = pures
108
- self .luck = luck
109
-
110
- class Mage (Player ):
111
- pass
112
-
113
- class Warrior (Player ):
114
- ##-- Adrenaline Junky --##
115
- ##-- Lets Warrior the ablity to take 1 hits before death --##
116
- ##-- Ability can level up as player gets stronger --##
117
- pass
118
-
119
- class Archer (Player ):
120
- pass
121
-
122
- class Assassin (Player ):
123
- pass
124
-
125
55
##-- Main() is the first function --##
126
56
##-- Gets input from player to either Start Load Help or Exit --##
127
57
@@ -234,24 +164,24 @@ def class_selection():
234
164
##-- class to be Mage, Warrior, Archer or Assassin --##
235
165
##-- Mage --##
236
166
if player_class_choice == 'Mage' :
237
- player_in_game = Mage (player_name ,'Mage' ,max_health = 80 ,melee_attack = 1 ,magic_attack = 10 ,
167
+ player_in_game = Mage (char_name = player_name , player_class = 'Mage' ,max_health = 80 ,melee_attack = 1 ,magic_attack = 10 ,
238
168
max_mana = 50 , max_stamina = 10 , defense = 1 , pures = 0 , luck = 1 )
239
- player_inventory . in_hand = Items .weak_staff
169
+ player_in_game . equipped_weapon = Items .weak_staff
240
170
##-- Warrior --##
241
171
elif player_class_choice == 'Warrior' :
242
- player_in_game = Warrior (player_name ,'Warrior' ,max_health = 150 ,melee_attack = 10 ,magic_attack = 0 ,
172
+ player_in_game = Warrior (char_name = player_name , player_class = 'Warrior' ,max_health = 150 ,melee_attack = 10 ,magic_attack = 0 ,
243
173
max_mana = 5 , max_stamina = 50 , defense = 4 , pures = 0 , luck = 0 )
244
- player_inventory . in_hand = Items .rusty_short_sword
174
+ player_in_game . equipped_weapon = Items .rusty_short_sword
245
175
##-- Archer --##
246
176
elif player_class_choice == 'Archer' :
247
- player_in_game = Archer (player_name ,'Archer' ,max_health = 100 ,melee_attack = 5 ,magic_attack = 0 ,
177
+ player_in_game = Archer (char_name = player_name , player_class = 'Archer' ,max_health = 100 ,melee_attack = 5 ,magic_attack = 0 ,
248
178
max_mana = 50 , max_stamina = 10 , defense = 1 , pures = 0 , luck = 5 )
249
- player_inventory . in_hand = Items .common_hunting_bow
179
+ player_in_game . equipped_weapon = Items .common_hunting_bow
250
180
##-- Assassin --##
251
181
elif player_class_choice == 'Assassin' :
252
- player_in_game = Assassin (player_name ,'Assassin' ,max_health = 50 ,melee_attack = 20 ,magic_attack = 10 ,
182
+ player_in_game = Assassin (char_name = player_name ,player_class = 'Assassin' ,max_health = 50 ,melee_attack = 20 ,magic_attack = 10 ,
253
183
max_mana = 25 , max_stamina = 10 , defense = 2 , pures = 100 , luck = 10 )
254
- player_inventory . in_hand = Items .rusty_dagger
184
+ player_in_game . equipped_weapon = Items .rusty_dagger
255
185
256
186
gender_call ()
257
187
##-- Back to main loop --##
@@ -260,15 +190,12 @@ def class_selection():
260
190
##-- Makes a random mob with in the range of the players level --##
261
191
262
192
def random_enemy ():
263
- global mob
264
- biome_info = Engine .get_tile (x ,y )
193
+ biome_info = Engine .get_tile (x ,y )
265
194
spawns = Biome .world_biomes [biome_info [0 ][2 ]]['spawns' ]
266
195
if spawns == ["None" ]:
267
- mob = "X"
268
- return
196
+ return None
269
197
random_mob = random .choice (spawns )
270
- mob = Mobs .hostail_mobs [random_mob ]
271
- # mob = Mobs.random_enemy(player_in_game.level)
198
+ return hostile_mobs [random_mob ]
272
199
273
200
##-- Encounter is to handle if we fight or not --##
274
201
##-- This probably needs some work --##
@@ -280,9 +207,10 @@ def encounter():
280
207
##-- num is subject to change as I add possible encounters --##
281
208
282
209
num = random .randint (1 , 1000 )
283
- random_enemy ()
210
+ mob = random_enemy ()
284
211
clear ()
285
- print (f"You ran in a { mob .name } on the path." )
212
+ if mob is not None :
213
+ print (f"You ran in a { mob .char_name } on the path." )
286
214
pause ()
287
215
#combat()
288
216
if biome_or_subBiome == False :
@@ -308,64 +236,64 @@ def level_up(player):
308
236
309
237
##-- This is to set up the fighting system --##
310
238
311
- def combat ():
239
+ def combat (mob ):
312
240
313
241
clear ()
314
242
Screen .vs_screen (player_in_game , mob )
315
- Screen .stat_screen (player_in_game , player_inventory , mob )
243
+ Screen .stat_screen (player_in_game , mob )
316
244
option = input ('\n (1): Attack\n (2): Magic\n (3): Use Item\n (4): Run\n Choose A Number:> ' )
317
245
318
246
if option == '1' :
319
- attack ()
247
+ attack (mob )
320
248
321
249
elif option == '2' :
322
- magic ()
250
+ magic (mob )
323
251
324
252
elif option == '3' :
325
- use_item ()
253
+ use_item (mob )
326
254
327
255
elif option == '4' :
328
- run ()
256
+ run (mob )
329
257
##-- Attack handles melee and magic attacks --##
330
258
##-- Unlike most games magic attacks aren't --##
331
259
##-- Just spells "magic attack" uses the --##
332
260
##-- Magic of the weapon in hand to deal --##
333
261
##-- Damage. But spells will be delt with a --##
334
262
##-- Different functions --##
335
263
336
- def attack ():
264
+ def attack (mob ):
337
265
338
- player_melee_attack = random .randint (round (player_in_game .melee_attack / 2 ), player_in_game .melee_attack + player_inventory . equiped_weapon .melee_damage )
339
- player_magic_attack = random .randint (round (player_in_game .magic_attack / 2 ), player_in_game .magic_attack + player_inventory . equiped_weapon .magic_damage )
266
+ player_melee_attack = random .randint (round (player_in_game .melee_attack / 2 ), player_in_game .melee_attack + player_in_game . equipped_weapon .melee_damage )
267
+ player_magic_attack = random .randint (round (player_in_game .magic_attack / 2 ), player_in_game .magic_attack + player_in_game . equipped_weapon .magic_damage )
340
268
enemy_attack = random .randint (round (mob .melee_attack / 2 ), mob .melee_attack )
341
269
clear ()
342
270
Screen .vs_screen (player_in_game , mob )
343
- Screen .stat_screen (player_in_game ,player_inventory , mob )
271
+ Screen .stat_screen (player_in_game , mob )
344
272
attack_type = input ('\n (1): Melee Attack\n (2): Magic Attack\n Choose A Number:> ' )
345
273
if attack_type == '1' :
346
274
if player_melee_attack == player_in_game .melee_attack / 2 : ##-- Player Attack --##
347
- print (f"\n { player_in_game .name } { player_inventory . in_hand .action_word } " ) ##-- finish me --##
275
+ print (f"\n { player_in_game .name } { player_in_game . equipped_weapon .action_word } " ) ##-- finish me --##
348
276
else :
349
277
mob .health -= player_melee_attack
350
278
clear ()
351
279
print (f'\n You just dealed { player_melee_attack } damage.' )
352
280
353
281
input ('\n Pess Enter To Continue:> ' )
354
282
if mob .health <= 0 :
355
- win ()
283
+ win (mob )
356
284
357
285
if enemy_attack == round (mob .melee_attack / 2 ): ##-- Mob Attack --##
358
286
clear ()
359
- print (f'\n { mob .name } missed!' )
287
+ print (f'\n { mob .char_name } missed!' )
360
288
else :
361
289
player_in_game .health -= enemy_attack
362
290
clear ()
363
- print (f'\n { mob .name } just dealed { enemy_attack } damage to you.' )
364
- input ('\n Pess Enter To Continue:> ' )
291
+ print (f'\n { mob .char_name } just dealed { enemy_attack } damage to you.' )
292
+ input ('\n Press Enter To Continue:> ' )
365
293
if player_in_game .health <= 0 :
366
- dead ()
294
+ dead (mob )
367
295
else :
368
- combat ()
296
+ combat (mob )
369
297
370
298
elif attack_type == '2' :
371
299
@@ -379,36 +307,36 @@ def attack():
379
307
380
308
input ('\n Press Enter To Continue:> ' )
381
309
if mob .health <= 0 :
382
- win ()
310
+ win (mob )
383
311
384
312
if enemy_attack == round (mob .magic_attack / 2 ): ##-- Mob Attack --##
385
313
clear ()
386
- print (f'\n { mob .name } missed!' )
314
+ print (f'\n { mob .char_name } missed!' )
387
315
else :
388
316
player_in_game .health -= enemy_attack
389
317
clear ()
390
- print (f'\n { mob .name } just dealed { enemy_attack } damage to you.' )
318
+ print (f'\n { mob .char_name } just dealed { enemy_attack } damage to you.' )
391
319
input ('\n Pess Enter To Continue:> ' )
392
320
if player_in_game .health <= 0 :
393
- dead ()
321
+ dead (mob )
394
322
else :
395
- combat ()
323
+ combat (mob )
396
324
397
325
##-- Handles Spell Attacks and Healing or what ever else I can dream up --##
398
- def magic ():
326
+ def magic (mob ):
399
327
print ("not working yet. Sorry!" )
400
328
pause ()
401
- attack ()
329
+ attack (mob )
402
330
403
331
##-- Handles the use of potions or and other usable item --##
404
332
##-- In combat or out --##
405
- def use_item ():
333
+ def use_item (mob ):
406
334
print ("not working yet. Sorry!" )
407
335
pause ()
408
- attack ()
336
+ attack (mob )
409
337
410
338
##-- Run or Flee is to get away from the enemy in a fight --##
411
- def run ():
339
+ def run (mob ):
412
340
running = random .randint (1 , 3 )
413
341
if running == 1 :
414
342
clear ()
@@ -422,34 +350,34 @@ def run():
422
350
enemy_attack = random .randint (round (mob .melee_attack / 2 ), mob .melee_attack )
423
351
if enemy_attack == round (mob .melee_attack / 2 ):
424
352
clear ()
425
- print (f'\n { mob .name } missed!' )
353
+ print (f'\n { mob .char_name } missed!' )
426
354
else :
427
355
player_in_game .health -= enemy_attack
428
356
clear ()
429
- print (f'\n { mob .name } just dealed { enemy_attack } damage to you.' )
357
+ print (f'\n { mob .char_name } just dealed { enemy_attack } damage to you.' )
430
358
input ('\n Pess Enter To Continue:> ' )
431
359
if player_in_game .health <= 0 :
432
- dead ()
360
+ dead (mob )
433
361
else :
434
- combat ()
362
+ combat (mob )
435
363
436
364
##-- If you when a fight this function handles what happens --##
437
365
438
- def win ():
366
+ def win (mob ):
439
367
clear ()
440
368
player_in_game .pures += mob .pures
441
369
player_in_game .exp += mob .exp_gained
442
- message = f"You just defeated a { mob .name } \n Gold Looted: { mob .pures } \n EXP Gained: { mob .exp_gained } "
370
+ message = f"You just defeated a { mob .char_name } \n Gold Looted: { mob .pures } \n EXP Gained: { mob .exp_gained } "
443
371
print (message )
444
- input ('\n Pess Enter To Continue:> ' )
372
+ input ('\n Press Enter To Continue:> ' )
445
373
if biome_or_subBiome == False :
446
374
main_game_loop ()
447
375
else :
448
376
sub_map_move ()
449
377
##-- If in an unfortunate event the player dies this function is called --##
450
378
451
- def dead ():
452
- print (f'You have died from { mob .name } ' )
379
+ def dead (mob ):
380
+ print (f'You have died from { mob .char_name } ' )
453
381
pause ()
454
382
main ()
455
383
@@ -460,7 +388,7 @@ def get_resouces():
460
388
random_item = random .choice (biome_item )
461
389
item = Items .resources [random_item ]
462
390
463
- player_inventory . add_item (item )
391
+ player_in_game . add_to_inventory (item )
464
392
pause ()
465
393
if biome_or_subBiome == False :
466
394
main_game_loop ()
@@ -469,8 +397,8 @@ def get_resouces():
469
397
470
398
471
399
def look_in_inventory ():
472
- print (player_inventory . bag )
473
- print (player_inventory . inventory_item_limit )
400
+ print (player_in_game . inventory )
401
+ print (player_in_game . inventory_limit )
474
402
pause ()
475
403
if biome_or_subBiome == False :
476
404
main_game_loop ()
@@ -588,7 +516,7 @@ def main_game_loop():
588
516
# print('Loading...........')
589
517
if opening == True :
590
518
591
- Story .intro_story (player_in_game .name )
519
+ Story .intro_story (player_in_game .char_name )
592
520
input ("Press Enter to continue: " )
593
521
opening = False
594
522
map_info = Engine .get_tile (x ,y )
0 commit comments