Fix hair, dick around with new game screen.
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / ActionNode.as
blob9c3f371600b3a6c7109f736cbe7280d1df7f8f45
1 package org.sevenchan.dongs
3 import org.sevenchan.dongs.screens.Encounter;
4 /**
5 * Calls a function instead of spewing a bunch of text and giving you a menu.
6 * @author ...
7 */
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;
16 public var arg:*;
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:*)
21 this._cost = cost;
22 this._name = name;
23 this._desc = desc;
24 this._parent = parent;
25 this.callback = callback;
26 this.arg = arg;
29 public function get name():String {
30 return _name;
32 public function get description():String {
33 return _desc;
35 public function get children():Vector.<INode> {
36 return _children;
38 public function get content():String {
39 return _content;
41 public function get parent():INode {
42 return _parent;
44 public function get cost():Number {
45 return _cost;
47 public function set content(value:String):void {
48 _content=value;
51 public function set canGoBack(value:Boolean):void {
52 _canGoBack = value;
54 public function get canGoBack():Boolean{
55 return _canGoBack;
60 public function pushChild(c:INode):void {
61 _children.push(c);
64 public function pushMenu(name:String, desc:String, conditionalCallback:Function=null):MenuNode {
65 var n:MenuNode = new MenuNode(this, name, desc, conditionalCallback);
66 pushChild(n);
67 return n;
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);
72 pushChild(n);
73 return n;
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);