Home

Wednesday, January 26, 2022

Python 3 Win 7 - RPG Systems - Simple Level System 2


 # Python Win 7

RPG Systems

Simple Level System 2

 

Brief:

_______________________________________________________________
A very short series made to help classmates in CS100 back in 2013.

 

Functionality :

_______________________________________________________________
Improvements:
  • N/A
Issues:
  • N/A

 

Demo:

_______________________________________________________________



Code snippet:

  _______________________________________________________________
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
char  = {'lvl'     : 1,
	'xp'       : 0,
	'lvl_next' : 25,
	}
stats = {'str' 	   : 1,
	 'dex' 	   : 1,
	 'int' 	   : 1,
	}


def update_level(char, stats):
	new_str, new_dex, new_int = 0, 0, 0
	while char['xp'] >= char['lvl_next']:
		char['lvl'] 	 += 1
		char['xp']       = char['xp'] - char['lvl_next']
		char['lvl_next'] = round(char['lvl_next'] * 1.5)
		new_str          += 1
		new_dex 	 += 1
		new_int 	 += 1

	print(f"level: {char['lvl']}")

	# The assignment as  I gave it last lesson:
	print(f"STR {stats['str']} +{new_str}",
	      f"DEX {stats['str']} +{new_dex}",
	      f"INT {stats['int']} +{new_int}"
	     )

	stats['str'] += new_str
	stats['dex'] += new_dex
	stats['int'] += new_int


char['xp'] += 25
update_level(char, stats)

print('-----------')

char['xp'] += 200
update_level(char, stats)

print('-----------')

char['xp'] += 200
update_level(char, stats)


Credits & Resources:

  • CS 100 - Tm R.
  • Code formatted via: http://hilite.me/ : Styling: Python, monokai

 

-END-

No comments:

Post a Comment

Conduct: Be nice and don't advertise or plug without adding value to the conversation.