This commit is contained in:
RafayAhmad7548 2024-09-09 16:59:28 +05:00
parent 2992f4f408
commit 4f46de8d00
3330 changed files with 394553 additions and 76939 deletions

View file

@ -0,0 +1,12 @@
class Player:
def __init__(self, name) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()

View file

@ -0,0 +1,61 @@
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)
self.check_cell(self.player.x, self.player.y)
game = DungeonGame('rafay')
while not game_over:
game.play_turn()

View file

@ -0,0 +1,22 @@
import random
class Player:
def __init__(self, name) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
pass
pass

View file

@ -0,0 +1,66 @@
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.game_over = False
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!!')
if self.player.health <= 0:
self.game_over = True
print('aaaaa my health, i die -- game over')
elif self.grid[x][y] == 'H':
if self.player.health < 100:
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)
self.check_cell(self.player.x, self.player.y)
game = DungeonGame('rafay')
while not game.game_over:
game.play_turn()

View file

@ -0,0 +1,30 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
for row in self.grid:
for i in range(5):
row.append(random.choice(['T', 'H', 'E']))
def display(self):
for row in self.grid:
for col in row:
print(col)
print()
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,67 @@
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.game_over = False
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!!')
if self.player.health <= 0:
self.game_over = True
print('aaaaa my health, i die -- game over')
elif self.grid[x][y] == 'H':
if self.player.health < 100:
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)
self.check_cell(self.player.x, self.player.y)
print('current player health: ', self.player.health)
game = DungeonGame('rafay')
while not game.game_over:
game.play_turn()

View file

@ -0,0 +1,58 @@
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)
self.check_cell(self.player.x, self.player.y)
game = DungeonGame('rafay')

View file

@ -0,0 +1,27 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
for row in self.grid:
row.append(random.choice(['T', 'H', 'E']))
def display(self):
for row in self.grid:
print(row)
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,13 @@
class Player:
def __init__(self, name) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]

View file

@ -0,0 +1,34 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
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()
game = DungeonGame('rafay')
while not game_over:
game.display()
a = input('enter a direction to move the player: ')

View file

@ -0,0 +1,27 @@
import random
class Player:
def __init__(self, name) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])
def display(self):
print(self.grid)
game = DungeonGame()
game.display()

View file

@ -0,0 +1,20 @@
import random
class Player:
def __init__(self, name) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]
def grid_init(self):
pass

View file

@ -0,0 +1,56 @@
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, y):
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():
game = DungeonGame('rafay')

View file

@ -0,0 +1,28 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
for row in self.grid:
for i in range(5):
row.append(random.choice(['T', 'H', 'E']))
def display(self):
for row in self.grid:
print(row)
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,30 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
for row in self.grid:
for i in range(5):
row.append(random.choice(['T', 'H', 'E']))
def display(self):
for row in self.grid:
for col in row:
print(col, end=' ')
print()
game = DungeonGame('rafay')
game.display()

View 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')

View file

@ -0,0 +1,56 @@
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():
game = DungeonGame('rafay')

View file

@ -0,0 +1,10 @@
class Player:
def __init__(self) -> None:
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
pass

View file

@ -0,0 +1,43 @@
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):
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()
game = DungeonGame('rafay')

View file

@ -0,0 +1,46 @@
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):
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()
game = DungeonGame('rafay')
while not game_over:
a = input('enter a direction to move the player: ')

View file

@ -0,0 +1,31 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
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()
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,27 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])
def display(self):
for row in self.grid:
print(row)
game = DungeonGame('rafay')
game.display()

View 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():
a = input('enter a character to move the player(l, r, u, d): ')
game = DungeonGame('rafay')

View file

@ -0,0 +1,27 @@
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
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])
def display(self):
print(self.grid)
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,27 @@
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
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])
def display(self):
print(self.grid)
game = DungeonGame()
game.display()

View file

@ -0,0 +1,54 @@
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):
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, y):
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')
game = DungeonGame('rafay')

View file

@ -0,0 +1,53 @@
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):
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, y):
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':
game = DungeonGame('rafay')

View file

@ -0,0 +1 @@
{"version":1,"resource":"file:///home/rafayahmad/Stuff/Coding/Python/IDS/Assg1/q4.py","entries":[{"id":"bhmF.py","source":"Create q4.py","timestamp":1725426932684},{"id":"sgko.py","timestamp":1725426949738},{"id":"Midg.py","timestamp":1725442035597},{"id":"grLX.py","timestamp":1725442055573},{"id":"02Qq.py","timestamp":1725445229868},{"id":"CYj1.py","timestamp":1725445303836},{"id":"IZaE.py","timestamp":1725445344068},{"id":"1EiM.py","timestamp":1725445366694},{"id":"gRyE.py","timestamp":1725445420356},{"id":"HMka.py","timestamp":1725445544145},{"id":"vyCf.py","timestamp":1725445571818},{"id":"afar.py","timestamp":1725445610024},{"id":"b6pR.py","timestamp":1725445623990},{"id":"kvT0.py","timestamp":1725445655966},{"id":"UY6X.py","timestamp":1725445673758},{"id":"siGO.py","timestamp":1725445689738},{"id":"A0Jx.py","timestamp":1725445777219},{"id":"IkBu.py","timestamp":1725445796468},{"id":"5ckz.py","timestamp":1725445821504},{"id":"KHtN.py","timestamp":1725445872829},{"id":"TiPK.py","timestamp":1725445923711},{"id":"EEDz.py","timestamp":1725445988556},{"id":"mm85.py","timestamp":1725446079963},{"id":"gDco.py","timestamp":1725446176957},{"id":"Q6EG.py","timestamp":1725446250212},{"id":"OWFK.py","timestamp":1725446293388},{"id":"ehJ4.py","timestamp":1725446466690},{"id":"brK9.py","timestamp":1725446479597},{"id":"IfDX.py","timestamp":1725446506908},{"id":"Mdp9.py","timestamp":1725446518002},{"id":"u6RW.py","timestamp":1725446558499},{"id":"YSe7.py","timestamp":1725446582883},{"id":"t9xB.py","timestamp":1725446615504},{"id":"Lf86.py","timestamp":1725446644615},{"id":"9zhQ.py","timestamp":1725453890639},{"id":"0h80.py","timestamp":1725453970462},{"id":"grhQ.py","timestamp":1725453993892},{"id":"obSq.py","timestamp":1725454046382},{"id":"1P6H.py","timestamp":1725454076348},{"id":"8EzY.py","timestamp":1725454122481},{"id":"qf9V.py","timestamp":1725454161854},{"id":"zQMR.py","timestamp":1725454186860}]}

View file

@ -0,0 +1,41 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
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()
game = DungeonGame('rafay')
while not game_over:
a = input('enter a direction to move the player: ')

View file

@ -0,0 +1,22 @@
import random
class Player:
def __init__(self, name) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])

View file

@ -0,0 +1,10 @@
class Player:
def __init__(self) -> None:
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()

View file

@ -0,0 +1,62 @@
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.game_over = False
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)
self.check_cell(self.player.x, self.player.y)
game = DungeonGame('rafay')
while not game_over:
game.play_turn()

View file

@ -0,0 +1,27 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])
def display(self):
print(self.grid)
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,33 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
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()
game = DungeonGame('rafay')
while not game_over:
a = input('enter a direction to move the player: ')

View file

@ -0,0 +1,65 @@
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.game_over = False
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!!')
if self.player.health <= 0:
self.game_over = True
print('aaaaa my health, i die -- game over')
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)
self.check_cell(self.player.x, self.player.y)
game = DungeonGame('rafay')
while not game_over:
game.play_turn()

View file

@ -0,0 +1,67 @@
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 < 4:
self.x += 1
elif direction == 'u':
if self.y > 0:
self.y += 1
elif direction == 'd':
if self.y < 4:
self.y -= 1
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.game_over = False
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!!')
if self.player.health <= 0:
self.game_over = True
print('aaaaa my health, i die -- game over')
elif self.grid[x][y] == 'H':
if self.player.health < 100:
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)
self.check_cell(self.player.x, self.player.y)
print('current player health: ', self.player.health)
game = DungeonGame('rafay')
while not game.game_over:
game.play_turn()

View file

@ -0,0 +1,3 @@
class DungeonGame:
def __init__(self) -> None:
pass

View file

@ -0,0 +1,28 @@
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
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.grid_init()
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])
def display(self):
for row in self.grid:
print(row)
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,56 @@
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():
a = input('enter a character to move the player(l, r, u, d): ')
game = DungeonGame('rafay')

View 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():
a = input('enter a character to move the player')
game = DungeonGame('rafay')

View file

@ -0,0 +1,27 @@
import random
class Player:
def __init__(self, name) -> None:
self.name = name
self.score = 0
self.health = 100
self.x = 0
self.y = 0
class DungeonGame:
def __init__(self) -> None:
self.player = Player()
self.grid = [[],[],[],[],[]]
def grid_init(self):
for row in self.grid:
for col in row:
col = random.choice(['T', 'H', 'E'])
def display(self):
print(self.grid)
game = DungeonGame('rafay')
game.display()

View file

@ -0,0 +1,67 @@
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 < 4:
self.x += 1
elif direction == 'u':
if self.y > 0:
self.y += 1
elif direction == 'd':
if self.y < 4:
self.y -= 1
class DungeonGame:
def __init__(self, name: str) -> None:
self.player = Player(name)
self.grid = [[],[],[],[],[]]
self.game_over = False
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!!')
if self.player.health <= 0:
self.game_over = True
print('aaaaa my health, i die -- game over')
elif self.grid[x][y] == 'H':
if self.player.health < 100:
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)
self.check_cell(self.player.x, self.player.y)
print('current player health: ', self.player.health)
game = DungeonGame('rafay')
while not game.game_over:
game.play_turn()