๊ณ ๋ คํด์ผ ๋ ๊ฒ ๋๋ฌด ๋ง์๋ค.
- ๋ฌด๊ธฐ/๋ฐฉ์ด๊ตฌ๋ ์์น์ ์๊ด์์ด ์ป์ ๋๋ง๋ค ๊ต์ฒด๋๋ค
- ๋ฐฉ์ด๊ตฌ๋ 4๊ฐ ์ด์ ์ฐฉ์ฉํ ์ ์๋ค.
- ์ด๋ฏธ ๋์ผํ ๋ฐฉ์ด๊ตฌ๋ฅผ ์ฐฉ์ฉํ๊ณ ์๋ ๊ฒฝ์ฐ์๋ ์ฐฉ์ฉํ ์ ์๋ค.
- ์ฐฉ์ฉํ ์ ์๋ ๊ฒฝ์ฐ์๋ ์์ดํ ์์๋ฅผ ์ด์๋ค๋ฉด ๋ฌด์กฐ๊ฑด ๋น ์นธ์ด ๋๋ค.
- ์ฃผ์ธ๊ณต์ด ์ฌ๋งํ์ง ์์ ์ฑ๋ก ๊ฒ์์ด ์ข ๋ฃ๋๋ค๋ฉด ๊ฐ์ ํจ์ ์์ ์๋๋ผ๋ ๋ฐ๋์ @๋ก ํ์๋์ด์ผ ํ๋ค.
- HR๋ก ์ฒด๋ ฅ์ด ํ๋ณต๋ ๋๋ ๋ฐ๋์ ์ต๋ ์ฒด๋ ฅ๊น์ง๋ง ํ๋ณต ๊ฐ๋ฅํ๋ค.
- RE๋ ์ฃผ์ธ๊ณต์ด ๋ชฌ์คํฐ์ ์ ํฌ ์ค/๊ฐ์ ํจ์ ์ ๋ฐ์์ ๋ ์ด๋ ๋๋ ์ฌ๋งํ๋ฉด ์ฌ์ฉ๋๋ฉฐ ์ฃผ์ธ๊ณต์ ๋ถํ์ํจ ํ ์๋ฉธ๋์ด์ผ ํ๋ค. ์ด๋ ์ฐฉ์ฉ ์ค์ธ ๋ฐฉ์ด๊ตฌ ๊ฐ์์์ 1์ ๋นผ์ผ ํ๋ค.
- CO๋ ์ฒซ ๋ฒ์งธ ๊ณต๊ฒฉ์์๋ง ๊ณต๊ฒฉ๋ ฅ์ 2๋ฐฐ๋ก ํ๋ค.
- DX์ CO๊ฐ ๋ ๋ค ์ฐฉ์ฉ๋์ด ์๋ ๊ฒฝ์ฐ์๋ง DX์ ๊ณต๊ฒฉ๋ ฅ 3๋ฐฐ ํจ๊ณผ๊ฐ ์ ์ฉ๋๋ค.
- HU๋ ๋ณด์ค ๋ชฌ์คํฐ์ ์ฒซ ๋ฒ์งธ ๊ณต๊ฒฉ์์๋ง ๊ณต๊ฒฉ๋ ฅ ํจ๊ณผ๋ฅผ 0์ผ๋ก ๋ง๋ ๋ค.
- ์ฃผ์ธ๊ณต์ด ์ฌ๋งํด์ ์ฒด๋ ฅ์ด ์์๊ฐ ๋์ด๋ 0์ผ๋ก ์ถ๋ ฅํด์ผ ํ๋ค.
- ์ ํฌ ์ค ์ฃผ์ธ๊ณต์ด ์ฌ๋งํ๋ค ๋ถํํ ๊ฒฝ์ฐ๋ ๋ชฌ์คํฐ์ ์ฒด๋ ฅ๋ ์์๋ณต๊ทํด์ผ ํ๋ค.
์ด ์ค์์ 9๋ฒ์ ์์ ๋ฐ๋ก ์ด๋์๋ ์์ด์ ์ง์ง ์ฝ์ง ์์ฒญ ํ๋ค๊ฐ ๋ฌธ์ ๋ค์ ์ฝ๊ณ ๊นจ๋ฌ์๋ค ใ ....
# RPG Extreme
from collections import defaultdict
def find_start(grid): # ์ถ๋ฐ ์์น ์ฐพ๊ธฐ
for i in range(len(grid)):
if '@' in grid[i]:
return i, grid[i].index('@')
def thron(): # ๊ฐ์ ์ฐ๋ฆฌ๊ธฐ
global HP, RESULT, ITEMS, ITEMS_CNT
HP -= 5+min(1, ITEMS['DX_THRON'])
if HP <= 0:
if ITEMS['RE']:
revival()
del ITEMS['RE']
ITEMS_CNT -= 1
return
RESULT = f'YOU HAVE BEEN KILLED BY SPIKE TRAP..'
def revival(): # ์ฃผ์ธ๊ณต ์ฌ๋งํ๋ฉด 1. ์ต๋ ์ฒด๋ ฅ ๋ถํ, 2. ์์ ์์น๋ก ์ด๋
global HP, r, c
HP = MAX_HP
r, c = SR, SC
def level_up():
global HP, MAX_HP, ATT, DEF, EXP, LV
if EXP >= 5*LV:
EXP = 0
LV += 1
MAX_HP += 5
ATT += 2
DEF += 2
HP = MAX_HP
def boss_battle(r, c, s, w, a, h, e): # ๋ณด์ค ๋ชฌ์คํฐ๋ ์ธ์ฐ๊ธฐ, ์ด๊ธฐ๋ฉด ๊ฒ์ ์ข
๋ฃ
global RESULT, grid, HP, ITEM, ITEMS_CNT, EXP
att_alpha = 1
if ITEMS['HU']: # HU ์ฅ์ ๊ตฌ ์์ผ๋ฉด ์ต๋ ์ฒด๋ ฅ ํ๋ณต
att_alpha = 0 # ์ฒซ ๊ณต๊ฒฉ์ด 0
HP = MAX_HP
h -= max(1, (ATT+W)*max(1, ITEMS['CO'], ITEMS['DX_ATT'])-a)
while True:
if h <= 0: # ๋ณด์ค ๋ชฌ์คํฐ๊ฐ ์ง๋ฉด ๊ฒ์ ์ข
๋ฃ
RESULT = 'YOU WIN!'
EXP = EXP+int(e*max(1, ITEMS['EX']))
HP = min(MAX_HP, HP+ITEMS['HR'])
level_up()
return
HP -= (max(1, w-(DEF+A)))*att_alpha
if HP <= 0: # ์ฃผ์ธ๊ณต์ด ์ง ๊ฒฝ์ฐ
grid[r][c] = 'M'
if ITEMS['RE']: # ๋ถํ ๊ฐ๋ฅ?
revival()
del ITEMS['RE']
ITEMS_CNT -= 1
return
RESULT = f'YOU HAVE BEEN KILLED BY {s}..'
return
att_alpha = 1
h -= max(1, (ATT+W)-a)
def battle(r, c, s, w, a, h, e): # ์ผ๋ฐ ๋ชฌ์คํฐ๋ ์ธ์ฐ๊ธฐ
global RESULT, grid, HP, ITEM, ITEMS_CNT, EXP
# ์ฃผ์ธ๊ณต์ ์ฒซ ๋ฒ์งธ ๊ณต๊ฒฉ
h -= max(1, (ATT+W)*max(1, ITEMS['CO'], ITEMS['DX_ATT'])-a)
while True:
if h <= 0:
del MONSTER[(r, c)]
grid[r][c] = '.'
EXP = EXP+int(e*max(1, ITEMS['EX']))
HP = min(MAX_HP, HP+ITEMS['HR'])
level_up()
return
# ๋ชฌ์คํฐ์ ๊ณต๊ฒฉ
HP -= max(1, w-(DEF+A))
if HP <= 0:
grid[r][c] = '&'
del MONSTER[(r, c)]
if ITEMS['RE']:
revival()
del ITEMS['RE']
ITEMS_CNT -= 1
return
RESULT = f'YOU HAVE BEEN KILLED BY {s}..'
return
# ์ฃผ์ธ๊ณต์ ๊ณต๊ฒฉ
h -= max(1, (ATT+W)*max(1, ITEMS['CO'], ITEMS['DX_ATT'])-a)
def wear_item(t, s):
global ITEMS, ITEMS_CNT
# ์ฐฉ์ฉํ ์ฅ์ ๊ตฌ๊ฐ 4๊ฐ๊ฑฐ๋ ๋์ผํ ์ฅ์ ๊ตฌ๋ฅผ ์ฐฉ์ฉ์ค์ธ ๊ฒฝ์ฐ
if ITEMS_CNT == 4 or ITEMS[s]:
return
ITEMS_CNT += 1
if s == 'HR':
ITEMS['HR'] = 3
elif s == 'RE':
ITEMS['RE'] = 1
elif s == 'CO':
ITEMS['CO'] = 2
if ITEMS['DX_THRON']:
ITEMS['DX_ATT'] = 3
elif s == 'EX':
ITEMS['EX'] = 1.2
elif s == 'DX':
ITEMS['DX_THRON'] = -4
if ITEMS['CO']:
ITEMS['DX_ATT'] = 3
elif s == 'HU':
ITEMS['HU'] = 1
elif s == 'CU':
ITEMS['CU'] = 1
def open_box(r, c): # ๋ฐ์ค ์ด๊ธฐ
global W, A
t, s = BOXES[(r, c)]
del BOXES[(r, c)]
if t == 'W':
W = s
elif t == 'A':
A = s
else:
wear_item(t, s)
grid[r][c] = '.'
# INIT
HP, MAX_HP, ATT, DEF, EXP, LV, W, A, ITEMS, ITEMS_CNT = 20, 20, 2, 2, 0, 1, 0, 0, defaultdict(int), 0
MOVE = {'L': (0, -1), 'R': (0, 1), 'U': (-1, 0), 'D': (1, 0)}
MONSTER, BOXES = {}, {}
ACTION = {
'^': lambda x: thron(),
'B': lambda x: open_box(*x),
'&': lambda x: battle(*x, *MONSTER[*x]),
'M': lambda x: boss_battle(*x, *MONSTER[*x])
}
RESULT = 'Press any key to continue.'
# INPUT
n, m = map(int, input().split())
grid = [list(input()) for _ in range(n)]
direction = input()
K = sum(row.count('&') for row in grid)+1
L = sum(row.count('B') for row in grid)
for _ in range(K):
r, c, *info = map(lambda x: int(x) if x.isdigit() else x, input().split())
MONSTER[(r-1, c-1)] = info
for _ in range(L):
r, c, *ts = map(lambda x: int(x) if x.isdigit() else x, input().split())
BOXES[(r-1, c-1)] = ts
SR, SC = find_start(grid)
r, c = SR, SC
# GAME_START
turns = 0
for d in direction:
turns += 1
dr, dc = MOVE[d]
if grid[r][c] != '^':
grid[r][c] = '.'
if -1<r+dr<n and -1<c+dc<m and grid[r+dr][c+dc] != '#':
r += dr
c += dc
if grid[r][c] != '.':
ACTION[grid[r][c]]((r, c))
if grid[r][c] != '^' and not RESULT.startswith('YOU HAVE'):
grid[r][c] = '@'
if RESULT != 'Press any key to continue.':
break
else:
grid[r][c] = '@'
for row in grid:
print(''.join(row))
print(f"Passed Turns : {turns}")
print("LV :", LV)
print(f"HP : {max(0, HP)}/{MAX_HP}")
print(f"ATT : {ATT}+{W}")
print(f"DEF : {DEF}+{A}")
print(f"EXP : {int(EXP)}/{5*LV}")
# print(ITEMS, ITEMS_CNT, MONSTER)
print(RESULT)