File size: 1,865 Bytes
fdcbf65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from helper import run_action
from typing import Dict, List


# Implement basic movement logic for the player.
class Player:
    def __init__(self, name):
        self.name = name
        self.health = 100
        self.max_health = 100
        self.level = 1
        self.exp = 0
        self.exp_to_level = 100
        self.position = [0, 0]
        self.inventory = []
        self.current_quest = None
        self.completed_quests = []
        self.skills = {"combat": 1, "stealth": 1, "magic": 1}

    def gain_exp(self, amount: int) -> bool:
        """Award experience and handle leveling"""
        self.exp += amount
        if self.exp >= self.exp_to_level:
            self.level_up()
            return True
        return False

    def level_up(self):
        """Handle level up effects"""
        self.level += 1
        self.exp -= self.exp_to_level
        self.exp_to_level = int(self.exp_to_level * 1.5)
        self.max_health += 10
        self.health = self.max_health

    def add_quest(self, quest: Dict):
        """Add a new quest to track"""
        self.current_quest = quest

    def complete_quest(self, quest: Dict):
        """Complete a quest and gain rewards"""
        if quest in self.completed_quests:
            return False

        self.completed_quests.append(quest)
        self.gain_exp(quest.get("exp_reward", 50))
        return True

    def interact(self, npc, game_state):
        """Get AI-generated dialogue with NPCs"""
        prompt = f"You talk to {npc.name}. What do they say?"
        dialogue = run_action(prompt, [], game_state)
        return dialogue

    def examine(self, item, game_state):
        """Get AI-generated item description"""
        prompt = f"You examine the {item.name} closely. What do you discover?"
        description = run_action(prompt, [], game_state)
        return description