Add method to reset talk count
[wgj58.git] / wgj58.js
index 4810116a51023e074e355e27fcfa641d990459d4..2c503f0829a15065ad0859591ef4640b72353a0f 100644 (file)
--- a/wgj58.js
+++ b/wgj58.js
@@ -172,7 +172,7 @@ class GameNPC extends Phaser.Sprite {
                this.fullname = fullname;
                this.interaction_distance = interaction_distance;
                this.interactable = false;
-               this.talkcount = 0;
+               this.resetTalk();
                this.happy = false;
        }
 
@@ -218,6 +218,10 @@ class GameNPC extends Phaser.Sprite {
                return true;
        }
 
+       resetTalk() {
+               this.talkcount = 0;
+       }
+
        makeHappy() {
                this.happy = true;
                console.log(this.shortname, "is happy!");
@@ -281,8 +285,6 @@ class NPC_Clara extends GameNPC {
                                        { actor: logic.player, text: "Would you go out on a date with me?" },
                                        { actor: this, text: "..." },
                                        { actor: this, text: "No." } ] ));
-                               // FIXME: Clara should have another happy condition.
-                               this.makeHappy();
                                break;
                        default:
                                logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "..." } ] ));
@@ -530,7 +532,7 @@ class NPC_Saiki extends GameNPC {
 
 class NPC_Peter extends GameNPC {
        actionTalk() {
-               if (logic.carlos.alive) {
+               if (logic.saiki.alive) {
                        switch (this.talkcount) {
                                case 0:
                                        logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "Hi Peter! What's up?" },
@@ -560,6 +562,7 @@ class NPC_Peter extends GameNPC {
                                                        { actor: this, text: "You should know it's against the company etiquette..." },
                                                        { actor: this, text: "Regardless, I don't think she's really mad. You're a cool guy." },
                                                        { actor: logic.player, text: "I hope this will be sorted out... I totally accept her answer, but I wouldn't like her to have negative feelings towards me." } ] ));
+                                               this.offscreenTeleportation(new Phaser.Point(logic.clara.x - 160, logic.clara.y), this.tpDone, this);
                                        }
                                        else {
                                                logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "I'm kind of busy, man." } ] ));
@@ -613,9 +616,91 @@ class NPC_Peter extends GameNPC {
        endTalk() {
                return (logic.saiki.alive) && (this.talkcount < 3);
        }
+
+       tpDone(value) {
+               console.log("Woot-woot! Teleport complete:", value);
+               value.makeHappy();
+               logic.clara.makeHappy();
+               // FIXME: Need to find a prettier way than this.
+               logic.clara.update = function() { };            // Disable Clara's interaction. (Peter will talk for him.)
+       }
 }
 
 class NPC_Bianca extends GameNPC {
+       actionTalk() {
+               if (logic.peter.alive) {
+                       switch (this.talkcount) {
+                               case 0:
+                                       logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "... Hi Bianca!" },
+                                               { actor: this, text: "... Hello John!" },
+                                               { actor: logic.player, text: "So I've been told, you've been spending most of the day in this meeting room..." },
+                                               { actor: this, text: "Yeah?" },
+                                               { actor: logic.player, text: "... Your colleagues want to hold a meeting in this room and you're blocking it." },
+                                               { actor: this, text: "Hmm... Kind of that's the point... There is no need for that meeting." },
+                                               { actor: logic.player, text: "May I know why?" },
+                                               { actor: this, text: "You must have heard about the layoffs. We weren't happy with that, but it was inevitable to meet the productivity requirements." },
+                                               { actor: this, text: "But today morning, I received a list with about 50% of the employees... Many of them are great friends of mine..." },
+                                               { actor: this, text: "We were like a big family here and we're torn apart like this... The worst is that I have to tell the news to all of them." },
+                                               { actor: logic.player, text: "That's rough. Does this company even need people?" },
+                                               { actor: this, text: "..." } ] ));
+                                       logic.openDoor("cutedoor");
+                                       logic.closeDoor("peterdoor");
+                                       break;
+                               case 1:
+                                       logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "Bianca... Am I on that list?" },
+                                               { actor: this, text: "Yes, John." },
+                                               { actor: this, text: "Well, I'll try to convince them to keep you and many other great folks from the list." },
+                                               { actor: this, text: "But... I can't promise anything. Also, it would help your case a lot if you made some notable work today, so I could mention it as your recent achievement." },
+                                               { actor: logic.player, text: "Thank you very much... I'll see what I can do." } ] ));
+                                       break;
+                               case 2:
+                                       logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "You seem to be somehow blaming yourself. It's not your fault. You're just doing your job." },
+                                               { actor: this, text: "I know. It's just part of my work..." },
+                                               { actor: this, text: "But if you have to sweep out such a great volume of people within such a short time... It does take its toll on the person." },
+                                               { actor: this, text: "... I feel like I'm growing distant from the company." },
+                                               { actor: this, text: "I mean... probably it's heresy to say that, but I feel I can less and less identify with the company's values." },
+                                               { actor: logic.player, text: "Yeah, you should definitely not talk about it to others... I mean, maybe only those you deeply trust." },
+                                               { actor: this, text: "I don't care anymore..." },
+                                               { actor: logic.player, text: "Fine." },
+                                               { actor: logic.player, text: "See... probably there is no need for such drama. Maybe it's for the best for everyone." },
+                                               { actor: logic.player, text: "... After all, there IS life beyond the company..." },
+                                               { actor: this, text: "You think so?..." },
+                                               { actor: this, text: "Hmm..." },
+                                               { actor: this, text: "I never thought about it for a long time..." },
+                                               { actor: logic.player, text: "There are plenty of other opportunities for us! Everything will be fine!" },
+                                               { actor: this, text: "..." },
+                                               { actor: this, text: "Thank you. This helped me to regain a bit of my composure..." },
+                                               { actor: logic.player, text: "You're welcome." } ] ));
+                                       this.makeHappy();
+                                       break;
+                               default:
+                                       logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "Thank you. I'll go back to work soon. Just give some more minutes of alone time." } ] ));
+                       }
+               }
+               else {
+                       switch (this.talkcount) {
+                               case 0:
+                                       logic.gameinterface.talk(new Dialogue( [ { actor: logic.player, text: "..." },
+                                               { actor: this, text: "... So you came for me too." },
+                                               { actor: this, text: "..." },
+                                               { actor: this, text: "I know what you are..." },
+                                               { actor: this, text: "..." },
+                                               { actor: this, text: "Let's get over with." },
+                                               { actor: logic.player, text: "..." } ] ));
+                                       break;
+                               default:
+                                       logic.gameinterface.talk(new Dialogue( [ { actor: this, text: "What are you waiting for?" } ] ));
+                       }
+               }
+               super.actionTalk();
+       }
+
+       actionLeave() {
+               if (this.happy) {
+                       logic.gameinterface.dropNotice(this.shortname + ": Thank you. I'll go back to work soon.");
+               }
+       }
+
        actionTake() {
                // All doors open for you if you have all the cards.
                logic.openDoor("cutedoor");
@@ -634,8 +719,7 @@ class GameInterface extends Phaser.Group {
                this.back_notice.drawRect(0, 0, game.width, 30);
                this.back_notice.endFill();
                this.add(this.back_notice);
-               this.text_notice = new Phaser.Text(game, 0, this.back_notice.y, null, { align: 'left', fill: 'white', font: 'Ubuntu Mono', fontSize: 18, fontWeight: 'bold' });
-               this.text_notice.anchor.setTo(-0.5, -0.2);
+               this.text_notice = new Phaser.Text(game, 125, this.back_notice.y + 5, null, { align: 'left', fill: 'white', font: 'Ubuntu Mono', fontSize: 18, fontWeight: 'bold' });
                this.add(this.text_notice);
                this.clearNotice();