-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeople.py
54 lines (51 loc) · 2.19 KB
/
people.py
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
from person import Person
import random
class People:
def __init__(self):
self.people = {}
self.num_talking = 0
self.available_to_talk = []
self.counter = 0
def add_person(self, name, path, num_div, width, height):
"""Creates person:
- load sprite from sprite sheet
- creates person object
"""
person = Person(name, path, num_div, width, height)
self.people[name] = person
if person.name != "mc":
self.available_to_talk.append(person)
def initiate_convo(self, curr_time, messages, toxicity):
event = None
if self.counter <= 0:
if len(self.available_to_talk) >= 2:
num_talking = random.randint(0, int(len(self.available_to_talk) / 2))
print(num_talking)
for _ in range(num_talking):
p1 = self.available_to_talk[random.randint(0, len(self.available_to_talk)-1)]
self.available_to_talk.remove(p1)
p1.walking = True
p2 = self.available_to_talk[random.randint(0, len(self.available_to_talk)-1)]
while p2 == p1.prev_talked_to:
p2 = self.available_to_talk[random.randint(0, len(self.available_to_talk)-1)]
self.available_to_talk.remove(p2)
p1.target = p2
p1.prev_talked_to = p2
p2.prev_talked_to = p1
event = p1.talk_to_target(p2, curr_time, messages, toxicity)
print(p1.name)
print(p2.name)
self.counter = 500
for person in self.people.values():
if not person.talking and person not in self.available_to_talk:
self.available_to_talk.append(person)
if person.talking:
if person.ttl > 0:
person.ttl -= 100
else:
print(person.target)
person.talking = False
person.walking = False
person.target = None
self.counter -= 10
return event