ziyadsuper2017 commited on
Commit
e23d62d
·
1 Parent(s): e5e9637

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -39
app.py CHANGED
@@ -32,45 +32,6 @@ safety_settings = [
32
  }
33
  ]
34
 
35
- # Define a Pokemon class that represents a Pokemon character with attributes and methods
36
- # A Pokemon has a name, a type, a health point (HP), a strength, and a list of attacks
37
- # Each attack has a name, a damage, a type, and a power point (PP)
38
- # A Pokemon can use an attack on another Pokemon, reducing its HP by the damage amount
39
- # A Pokemon can also heal itself by a certain amount, increasing its HP
40
- # Source: [Pokemon Class](https://stackoverflow.com/questions/12943297/builtins-attributeerror-str-object-has-no-attribute-name)
41
- class Pokemon(object):
42
- def __init__(self, name, etype, HP, strength, attacks):
43
- self.name = name
44
- self.etype = etype
45
- self.HP = HP
46
- self.strength = strength
47
- self.attacks = attacks # a dictionary of attacks with name, damage, type, and PP as values
48
-
49
- def use_attack(self, attack, target):
50
- # check if the attack is valid and has enough PP
51
- if attack in self.attacks and self.attacks[attack][3] > 0:
52
- # reduce the target's HP by the attack's damage
53
- target.HP -= self.attacks[attack][1]
54
- # reduce the attack's PP by 1
55
- self.attacks[attack][3] -= 1
56
- # print a message indicating the attack and the target's remaining HP
57
- print(f"{self.name} used {attack} on {target.name}!")
58
- print(f"{target.name}'s HP is now {target.HP}")
59
- else:
60
- # print a message indicating the attack is invalid or out of PP
61
- print(f"{self.name} cannot use {attack}!")
62
-
63
- def heal(self, amount):
64
- # increase the self's HP by the amount
65
- self.HP += amount
66
- # print a message indicating the healing and the self's remaining HP
67
- print(f"{self.name} healed itself by {amount}!")
68
- print(f"{self.name}'s HP is now {self.HP}")
69
-
70
- # Create some Pokemon instances with different attributes and attacks
71
- geodude = Pokemon("Geodude", "Ground", 100, 2, attacks = {"Tackle": ["Tackle", 30, "Normal", 35], "Rollout": ["Rollout", 50, "Rock", 20]})
72
- pikachu = Pokemon("Pikachu", "Lightning", 100, 3, attacks = {"Thunder Shock": ["Thunder Shock", 40, "Electric", 30], "Quick Attack": ["Quick Attack", 40, "Normal", 30]})
73
-
74
  # Initialize the chat history and the model instance using session state
75
  # Use the get function to avoid KeyError if the key does not exist
76
  chat_history = st.session_state.get("chat_history", [])
 
32
  }
33
  ]
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  # Initialize the chat history and the model instance using session state
36
  # Use the get function to avoid KeyError if the key does not exist
37
  chat_history = st.session_state.get("chat_history", [])