Fix hair, dick around with new game screen.
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / screens / Encounter.as
blob77eed3f96498eb68ed43384ca0e0259cb0b5addd
1 package org.sevenchan.dongs.screens
3 import org.sevenchan.dongs.MenuNode;
4 import org.sevenchan.dongs.Screen;
5 import org.sevenchan.dongs.*;
7 /**
8 * ...
9 * @author ...
11 public class Encounter extends Screen
13 protected var subject:Creature;
14 protected var text:String = "";
15 protected var abort:Boolean = false;
16 public var currentItem:INode = new MenuNode(null, "", "");
18 public function Encounter(target:Creature) {
19 subject = target;
20 if(target != null) {
21 currentItem.children.push(new ActionNode(currentItem, "Rape", 0, target.gender.doReplace("Try to rape %POS%."), performRape,null));
22 currentItem.children.push(new ActionNode(currentItem, "Fight", 0, target.gender.doReplace("Try to fight %POS%."), fight,null));
25 public function onStartupScreen():void { }
26 public function onLeaving():void { }
27 override public function processButtonPress(id:int):Boolean
29 clearButtons();
30 if (abort) {
31 return true;
33 switch (id)
35 case-1:
36 onStartupScreen();
37 appendMenu();
38 updateScreen();
39 return false;
40 break;
41 case 0:
42 if (currentItem.parent == null) {
43 onLeaving();
44 return true;
45 } else {
46 currentItem = currentItem.parent;
47 text = currentItem.content;
48 appendMenu();
49 updateScreen();
50 return false;
52 break;
53 default:
54 var nci:INode = currentItem.children[id-1];
55 var ret:Boolean = false;
56 if (nci is ActionNode) {
57 ret = (ActionNode(nci)).invoke(this, this.main.player);
58 } else {
59 if((MenuNode(nci)).canSwitchTo(main.player,subject,this)) {
60 currentItem = nci;
63 if(!abort)
64 text = nci.content;
65 if (!ret && !abort) {
66 appendMenu();
68 updateScreen();
69 return ret;
71 return false;
74 public function abortEncounter(text:String):void {
75 abort = true;
76 this.text = text;
77 clearButtons();
78 setButton(NEXT_BUTTON, "OK");
79 main.endCombat(null);
82 public function appendMenu():void {
83 text += "<ul>";
84 if(currentItem.canGoBack)
85 setButton(0, "BACK");
86 for (var i:int = 0; i < currentItem.children.length; i++) {
87 var nci:INode = currentItem.children[i];
88 var showButton:Boolean = true;
89 if (nci is ActionNode) {
90 if (!(ActionNode(nci)).hasEnoughMoney(main.player))
91 showButton=false;
93 text += "<li>";
94 if (showButton)
96 text += "<b>";
97 text += nci.name;
98 setButton(i + 1, nci.name);
99 } else {
100 text += "<i>";
101 text += nci.name;
102 text += "</i><b>";
104 if (nci is ActionNode && (nci as ActionNode).cost!=-1)
105 text += " (" + (nci as ActionNode).cost.toString() + "G)";
107 text += "</b> - ";
108 text += nci.description;
109 text += "</li>";
111 text += "</ul>";
115 override public function getScreenText():String
117 return text;
120 public function performRape(ply:Creature,node:ActionNode):Boolean {
121 main.startRape(null,this.subject,true);
122 return true;
125 public function fight(ply:Creature,node:ActionNode):Boolean {
126 main.startCombat(null, this.subject, true);
127 return true;