1 package org
.sevenchan
.dongs
.screens
3 import org
.sevenchan
.dongs
.MenuNode
;
4 import org
.sevenchan
.dongs
.Screen;
5 import org
.sevenchan
.dongs
.*;
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
) {
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
42 if (currentItem
.parent
== null) {
46 currentItem
= currentItem
.parent
;
47 text
= currentItem
.content
;
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
);
59 if((MenuNode
(nci
)).canSwitchTo
(main
.player
,subject
,this)) {
74 public function abortEncounter
(text
:String):void {
78 setButton
(NEXT_BUTTON
, "OK");
82 public function appendMenu
():void {
84 if(currentItem
.canGoBack
)
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
))
98 setButton
(i
+ 1, nci
.name
);
104 if (nci
is ActionNode
&& (nci
as ActionNode
).cost
!=-1)
105 text
+= " (" + (nci
as ActionNode
).cost
.toString
() + "G)";
108 text
+= nci
.description
;
115 override public function getScreenText
():String
120 public function performRape
(ply
:Creature
,node
:ActionNode
):Boolean {
121 main
.startRape
(null,this.subject
,true);
125 public function fight
(ply
:Creature
,node
:ActionNode
):Boolean {
126 main
.startCombat
(null, this.subject
, true);