update
This commit is contained in:
parent
2992f4f408
commit
4f46de8d00
3330 changed files with 394553 additions and 76939 deletions
57
.config/Code/User/History/-4c5a7b2f/Lf86.py
Normal file
57
.config/Code/User/History/-4c5a7b2f/Lf86.py
Normal file
|
@ -0,0 +1,57 @@
|
|||
import random
|
||||
|
||||
class Player:
|
||||
def __init__(self, name: str) -> None:
|
||||
self.name = name
|
||||
self.score = 0
|
||||
self.health = 100
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
|
||||
def move_player(self, direction: str) -> None:
|
||||
if direction == 'l':
|
||||
if self.x > 0:
|
||||
self.x -= 1
|
||||
elif direction == 'r':
|
||||
if self.x < 5:
|
||||
self.x += 1
|
||||
elif direction == 'u':
|
||||
if self.y > 0:
|
||||
self.y += 1
|
||||
elif direction == 'd':
|
||||
if self.y < 5:
|
||||
self.y -= 1
|
||||
|
||||
class DungeonGame:
|
||||
def __init__(self, name: str) -> None:
|
||||
self.player = Player(name)
|
||||
self.grid = [[],[],[],[],[]]
|
||||
self.grid_init()
|
||||
|
||||
def grid_init(self) -> None:
|
||||
for row in self.grid:
|
||||
for i in range(5):
|
||||
row.append(random.choice(['T', 'H', 'E']))
|
||||
self.grid[self.player.x][self.player.y] = '@'
|
||||
|
||||
# def display(self):
|
||||
# for row in self.grid:
|
||||
# for col in row:
|
||||
# print(col, end=' ')
|
||||
# print()
|
||||
|
||||
def check_cell(self, x: int, y: int) -> None:
|
||||
if self.grid[x][y] == 'T':
|
||||
self.player.health -= 20
|
||||
print('the player hit a trap, ouuuch!!')
|
||||
elif self.grid[x][y] == 'H':
|
||||
self.player.health += 10
|
||||
print('the player got a health potion, nom nom')
|
||||
elif self.grid[x][y] == 'E':
|
||||
print('ooo nothing here')
|
||||
|
||||
def play_turn(self):
|
||||
a = input('enter a character to move the player(l, r, u, d): ')
|
||||
self.player.move_player(a)
|
||||
|
||||
game = DungeonGame('rafay')
|
Loading…
Add table
Add a link
Reference in a new issue