1 package org
.sevenchan
.dongs
3 import org
.sevenchan
.dongs
.screens
.Encounter
;
5 * Calls a function instead of spewing a bunch of text and giving you a menu.
8 public class ActionNode
implements INode
10 private var _parent
:INode
=null;
11 private var _children
:Vector
.<INode
> = new Vector
.<INode
>();
12 private var _name
:String;
13 private var _desc
:String;
14 private var _cost
:int = -1;
15 private var _canGoBack
:Boolean = true;
17 public var callback
:Function;
18 private var _content
:String = "[?]";
19 public function ActionNode
(parent
:INode
,name
:String,cost
:int,desc
:String,callback
:Function,arg
:*)
24 this._parent
= parent
;
25 this.callback
= callback
;
29 public function get name
():String {
32 public function get description
():String {
35 public function get children
():Vector
.<INode
> {
38 public function get content
():String {
41 public function get parent
():INode
{
44 public function get cost
():Number {
47 public function set content
(value
:String):void {
51 public function set canGoBack
(value
:Boolean):void {
54 public function get canGoBack
():Boolean{
60 public function pushChild
(c
:INode
):void {
64 public function pushMenu
(name
:String, desc
:String, conditionalCallback
:Function=null):MenuNode
{
65 var n
:MenuNode
= new MenuNode
(this, name
, desc
, conditionalCallback
);
70 public function pushAction
(name
:String, cost
:int, desc
:String, callback
:Function,arg
:*=null):ActionNode
{
71 var n
:ActionNode
= new ActionNode
(this, name
, cost
, desc
, callback
,arg
);
76 public function invoke
(context
:Encounter
,ply
:Creature
, arg
:*=null):Boolean {
77 return callback
.call
(context
, ply
, this, arg
);
80 public function hasEnoughMoney
(ply
:Creature
):Boolean {
81 return ply
.gold
>= _cost
;
84 public function clearChildren
():void {
85 children
.splice
(0, children
.length
);