Where is the brandy? I need a drink.
Cat's Eye Technologies
11 years ago
40 | 40 | |
41 | 41 | # this will get filled in later |
42 | 42 | ALL_ITEMS = [] |
43 | ||
44 | # items that the mechanics need to know about; they will be defined later | |
45 | revolver = None | |
46 | brandy = None | |
43 | 47 | |
44 | 48 | ### EVENTS ### |
45 | 49 | |
189 | 193 | if self.collector: |
190 | 194 | self.collector.collect(Event(*args, **kwargs)) |
191 | 195 | |
192 | # if self.location is None, this is just an initial move | |
193 | 196 | def move_to(self, location): |
194 | 197 | if self.location: |
195 | 198 | self.location.contents.remove(self) |
250 | 253 | |
251 | 254 | |
252 | 255 | class QuestionTopic(Topic): |
256 | pass | |
257 | ||
258 | ||
259 | class WhereQuestionTopic(Topic): | |
253 | 260 | pass |
254 | 261 | |
255 | 262 | |
331 | 338 | self.emit("It was so nice being in <2> again", |
332 | 339 | [self, self.location], excl=True) |
333 | 340 | |
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 | ||
341 | 341 | # okay, look around you. |
342 | 342 | for x in self.location.contents: |
343 | 343 | if x == self: |
364 | 364 | self.emit( |
365 | 365 | "<1> noticed <2> <was-2> carrying <indef-3>", |
366 | 366 | [self, other, y]) |
367 | if revolver: | |
367 | if revolver.location == self: | |
368 | 368 | # this should be a ThreatTopic, below should |
369 | 369 | # be a RequestTopic -- er no, maybe not, but |
370 | 370 | # it would be nice if there was some way to |
371 | 371 | # indicate the revolver as part of the Topic |
372 | 372 | self.emit("<1> pointed <3> at <2>", |
373 | [self, other, revolver]) | |
374 | other.emit("<1> pointed <3> at <2>", | |
373 | 375 | [self, other, revolver]) |
374 | 376 | other.memory[revolver.name] = Memory(revolver, self) |
375 | 377 | self.address(other, |
379 | 381 | return |
380 | 382 | # another case of mind-reading. well, it helps the story advance! |
381 | 383 | # (it would help more to double-check this against your OWN memory) |
382 | if revolver: | |
384 | if revolver.location == self: | |
383 | 385 | for key in other.memory: |
384 | 386 | memory = other.memory[key] |
385 | 387 | self_memory = self.memory.get(key) |
388 | 390 | if memory.i_hid_it_there and memory.subject.name != 'revolver': |
389 | 391 | y = memory.subject |
390 | 392 | self.emit("<1> pointed <3> at <2>", |
393 | [self, other, revolver]) | |
394 | other.emit("<1> pointed <3> at <2>", | |
391 | 395 | [self, other, revolver]) |
392 | 396 | other.memory[revolver.name] = Memory(revolver, self) |
393 | 397 | self.address(other, |
420 | 424 | if y.treasure(): |
421 | 425 | fixated_on = y |
422 | 426 | 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 | |
428 | 429 | |
429 | 430 | # check if you are alone |
430 | 431 | for x in self.location.contents: |
476 | 477 | if memories: |
477 | 478 | memory = pick(memories) |
478 | 479 | picking_up = random.randint(0, 5) == 0 |
479 | if memory.subject.name == 'revolver': | |
480 | if memory.subject is revolver: | |
480 | 481 | picking_up = True |
481 | 482 | if picking_up: |
482 | 483 | if memory.i_hid_it_there: |
526 | 527 | "'Please don't shoot!', <1> cried, and handed over <3>", |
527 | 528 | [self, other, found_object]) |
528 | 529 | 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) | |
529 | 532 | elif isinstance(topic, ThreatTellMeTopic): |
530 | 533 | memory = self.memory.get(topic.subject.name) |
531 | 534 | if not memory: |
556 | 559 | subject=self_memory.subject) |
557 | 560 | return |
558 | 561 | if self_memory and other_memory: |
559 | choice = random.randint(0, 1) | |
562 | choice = random.randint(0, 2) | |
560 | 563 | if choice == 0: |
561 | 564 | self.question(other, "'Do you think we should do something about <3>?' asked <1>", |
562 | 565 | [self, other, self_memory.subject]) |
563 | 566 | if choice == 1: |
564 | 567 | self.speak_to(other, "'I think we should do something about <3>, <2>,' said <1>", |
565 | 568 | [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 | |
566 | 574 | # this needs to be not *all* the time |
567 | 575 | for x in other.contents: |
568 | 576 | if x.notable(): |
584 | 592 | self.speak_to(other, "'Perhaps, <2>,' replied <1>") |
585 | 593 | else: |
586 | 594 | 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) | |
587 | 623 | elif isinstance(topic, SpeechTopic): |
588 | 624 | choice = random.randint(0, 5) |
589 | 625 | if choice == 0: |
597 | 633 | if choice == 4: |
598 | 634 | self.speak_to(other, "'Oh, I know, I know,' said <1>") |
599 | 635 | 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>") | |
603 | 641 | |
604 | 642 | def wander(self): |
605 | 643 | self.move_to( |
737 | 775 | alice = Female('Alice', None) |
738 | 776 | bob = Male('Bob', None) |
739 | 777 | |
740 | ALL_ITEMS.extend([falcon, jewels, revolver]) | |
778 | ALL_ITEMS.extend([falcon, jewels, revolver, brandy]) | |
741 | 779 | |
742 | 780 | ### util ### |
743 | 781 |