git @ Cat's Eye Technologies The-Swallows / 9257141
Where is the brandy? I need a drink. Cat's Eye Technologies 11 years ago
1 changed file(s) with 59 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
4040
4141 # this will get filled in later
4242 ALL_ITEMS = []
43
44 # items that the mechanics need to know about; they will be defined later
45 revolver = None
46 brandy = None
4347
4448 ### EVENTS ###
4549
189193 if self.collector:
190194 self.collector.collect(Event(*args, **kwargs))
191195
192 # if self.location is None, this is just an initial move
193196 def move_to(self, location):
194197 if self.location:
195198 self.location.contents.remove(self)
250253
251254
252255 class QuestionTopic(Topic):
256 pass
257
258
259 class WhereQuestionTopic(Topic):
253260 pass
254261
255262
331338 self.emit("It was so nice being in <2> again",
332339 [self, self.location], excl=True)
333340
334 # am I carrying the revolver?
335 revolver = None
336 for z in self.contents:
337 if z.name == 'revolver':
338 revolver = z
339 break
340
341341 # okay, look around you.
342342 for x in self.location.contents:
343343 if x == self:
364364 self.emit(
365365 "<1> noticed <2> <was-2> carrying <indef-3>",
366366 [self, other, y])
367 if revolver:
367 if revolver.location == self:
368368 # this should be a ThreatTopic, below should
369369 # be a RequestTopic -- er no, maybe not, but
370370 # it would be nice if there was some way to
371371 # indicate the revolver as part of the Topic
372372 self.emit("<1> pointed <3> at <2>",
373 [self, other, revolver])
374 other.emit("<1> pointed <3> at <2>",
373375 [self, other, revolver])
374376 other.memory[revolver.name] = Memory(revolver, self)
375377 self.address(other,
379381 return
380382 # another case of mind-reading. well, it helps the story advance!
381383 # (it would help more to double-check this against your OWN memory)
382 if revolver:
384 if revolver.location == self:
383385 for key in other.memory:
384386 memory = other.memory[key]
385387 self_memory = self.memory.get(key)
388390 if memory.i_hid_it_there and memory.subject.name != 'revolver':
389391 y = memory.subject
390392 self.emit("<1> pointed <3> at <2>",
393 [self, other, revolver])
394 other.emit("<1> pointed <3> at <2>",
391395 [self, other, revolver])
392396 other.memory[revolver.name] = Memory(revolver, self)
393397 self.address(other,
420424 if y.treasure():
421425 fixated_on = y
422426 break
423 if not fixated_on and random.randint(0, 20) == 0:
424 for y in self.contents:
425 if y.name == 'revolver':
426 fixated_on = y
427 break
427 if not fixated_on and random.randint(0, 20) == 0 and revolver.location == self:
428 fixated_on = revolver
428429
429430 # check if you are alone
430431 for x in self.location.contents:
476477 if memories:
477478 memory = pick(memories)
478479 picking_up = random.randint(0, 5) == 0
479 if memory.subject.name == 'revolver':
480 if memory.subject is revolver:
480481 picking_up = True
481482 if picking_up:
482483 if memory.i_hid_it_there:
526527 "'Please don't shoot!', <1> cried, and handed over <3>",
527528 [self, other, found_object])
528529 found_object.move_to(other)
530 self.memory[found_object.name] = Memory(found_object, other)
531 other.memory[found_object.name] = Memory(found_object, other)
529532 elif isinstance(topic, ThreatTellMeTopic):
530533 memory = self.memory.get(topic.subject.name)
531534 if not memory:
556559 subject=self_memory.subject)
557560 return
558561 if self_memory and other_memory:
559 choice = random.randint(0, 1)
562 choice = random.randint(0, 2)
560563 if choice == 0:
561564 self.question(other, "'Do you think we should do something about <3>?' asked <1>",
562565 [self, other, self_memory.subject])
563566 if choice == 1:
564567 self.speak_to(other, "'I think we should do something about <3>, <2>,' said <1>",
565568 [self, other, self_memory.subject])
569 if choice == 2:
570 self.address(other, WhereQuestionTopic(self, subject=brandy),
571 "'Where is the brandy? I need a drink,' moaned <1>",
572 [self, other, self_memory.subject])
573 return
566574 # this needs to be not *all* the time
567575 for x in other.contents:
568576 if x.notable():
584592 self.speak_to(other, "'Perhaps, <2>,' replied <1>")
585593 else:
586594 self.speak_to(other, "'Perhaps, <2>,' replied <1>")
595 elif isinstance(topic, WhereQuestionTopic):
596 memory = self.memory.get(topic.subject.name)
597 if not memory:
598 self.speak_to(other,
599 "'I don't know,' <1> answered simply",
600 [self, other, topic.subject])
601 elif memory.i_hid_it_there:
602 self.question(other,
603 "'Why do you want to know where <3> is, <2>?'",
604 [self, other, topic.subject])
605 elif topic.subject.location == self:
606 self.speak_to(other,
607 "'I've got <3> right here, <2>. Here, take it.'",
608 [self, other, topic.subject])
609 topic.subject.move_to(other)
610 self.memory[topic.subject.name] = Memory(topic.subject, other)
611 other.memory[topic.subject.name] = Memory(topic.subject, other)
612 else:
613 if topic.subject.location.animate():
614 self.speak_to(other,
615 "'I think <3> has <4>,', <1> recalled",
616 [self, other, memory.location, topic.subject])
617 else:
618 self.speak_to(other,
619 "'I believe it's in <3>, <2>,', <1> recalled",
620 [self, other, memory.location])
621 other.memory[topic.subject.name] = \
622 Memory(topic.subject, memory.location)
587623 elif isinstance(topic, SpeechTopic):
588624 choice = random.randint(0, 5)
589625 if choice == 0:
597633 if choice == 4:
598634 self.speak_to(other, "'Oh, I know, I know,' said <1>")
599635 if choice == 5:
600 item = pick(ALL_ITEMS)
601 self.question(other, "'But what about <3>, <2>?' posed <1>",
602 [self, other, item], subject=item)
636 # -- this is getting really annoying. disable for now. --
637 # item = pick(ALL_ITEMS)
638 # self.question(other, "'But what about <3>, <2>?' posed <1>",
639 # [self, other, item], subject=item)
640 self.speak_to(other, "'I see, <2>, I see,' said <1>")
603641
604642 def wander(self):
605643 self.move_to(
737775 alice = Female('Alice', None)
738776 bob = Male('Bob', None)
739777
740 ALL_ITEMS.extend([falcon, jewels, revolver])
778 ALL_ITEMS.extend([falcon, jewels, revolver, brandy])
741779
742780 ### util ###
743781