From 6b91816defe292399d2c2ffd2434cca366b7b5f0 Mon Sep 17 00:00:00 2001 From: Masadow Date: Tue, 17 Jun 2014 23:25:30 +0200 Subject: [PATCH 1/6] Fix autologin on subscribe --- src/services/account/AccountService.hx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/account/AccountService.hx b/src/services/account/AccountService.hx index 193bf89..d7532e0 100644 --- a/src/services/account/AccountService.hx +++ b/src/services/account/AccountService.hx @@ -78,8 +78,10 @@ class AccountService implements MetadataReader { public function subscribeSuccess(user : User) { var html = Renderer.renderDefault("page_accueil", "Home", { success : "Subscribe succeeded !", - login: Beluga.getInstance().getModuleInstance(Account).getLoggedUser().login + login: user.login }); + //Autologin + Beluga.getInstance().getModuleInstance(Account).setLoggedUser(user); Sys.print(html); } From 1fd6cf48df65a41ef22b4bed9623b3bf2d701cc6 Mon Sep 17 00:00:00 2001 From: Masadow Date: Mon, 16 Jun 2014 22:29:14 +0200 Subject: [PATCH 2/6] Add Dominax --- assets/js/swfobject.js | 4 ++ dominax/Project.xml | 63 +++++++++++++++++++++++++++++++ dominax/source/GameClass.hx | 27 +++++++++++++ dominax/source/Main.hx | 53 ++++++++++++++++++++++++++ dominax/source/Player.hx | 31 +++++++++++++++ dominax/source/state/LoadState.hx | 52 +++++++++++++++++++++++++ dominax/source/state/PlayState.hx | 52 +++++++++++++++++++++++++ src/Assets.hx | 2 +- src/Main.hx | 28 +++++++++----- src/Server.hx | 25 ++++++++++++ src/game/Game.hx | 4 +- src/game/tpl/game_widget.mtt | 14 ++++++- src/main_view/tpl/htmlbody.mtt | 1 + 13 files changed, 344 insertions(+), 12 deletions(-) create mode 100644 assets/js/swfobject.js create mode 100644 dominax/Project.xml create mode 100644 dominax/source/GameClass.hx create mode 100644 dominax/source/Main.hx create mode 100644 dominax/source/Player.hx create mode 100644 dominax/source/state/LoadState.hx create mode 100644 dominax/source/state/PlayState.hx create mode 100644 src/Server.hx diff --git a/assets/js/swfobject.js b/assets/js/swfobject.js new file mode 100644 index 0000000..8eafe9d --- /dev/null +++ b/assets/js/swfobject.js @@ -0,0 +1,4 @@ +/* SWFObject v2.2 + is released under the MIT License +*/ +var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y0){for(var af=0;af0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad'}}aa.outerHTML='"+af+"";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dominax/source/GameClass.hx b/dominax/source/GameClass.hx new file mode 100644 index 0000000..1933d92 --- /dev/null +++ b/dominax/source/GameClass.hx @@ -0,0 +1,27 @@ +package; + +import flash.Lib; +import flixel.FlxGame; + +class GameClass extends FlxGame +{ + public static var host(default, null) : String; + public static var playerId(default, null) : Int; + + public function new() + { + var stageWidth:Int = Lib.current.stage.stageWidth; + var stageHeight:Int = Lib.current.stage.stageHeight; + + var ratioX:Float = stageWidth / 640; + var ratioY:Float = stageHeight / 480; + var ratio:Float = Math.min(ratioX, ratioY); + + var fps:Int = 60; + + host = Lib.current.loaderInfo.parameters.host; + playerId = Std.parseInt(Lib.current.loaderInfo.parameters.uid); + + super(Math.ceil(stageWidth / ratio), Math.ceil(stageHeight / ratio), state.PlayState, ratio, fps, fps); + } +} diff --git a/dominax/source/Main.hx b/dominax/source/Main.hx new file mode 100644 index 0000000..d5ba192 --- /dev/null +++ b/dominax/source/Main.hx @@ -0,0 +1,53 @@ +package; + +import flash.display.Sprite; +import flash.display.StageAlign; +import flash.display.StageScaleMode; +import flash.events.Event; +import flash.Lib; +import flixel.FlxGame; + +/** + * @author Joshua Granick + */ +class Main extends Sprite +{ + // Entry point + static public function main():Void + { + Lib.current.addChild(new Main()); + } + + public function new() + { + super(); + + if (stage != null) + { + init(); + } + else + { + addEventListener(Event.ADDED_TO_STAGE, init); + } + } + + private function init(?E:Event):Void + { + if (hasEventListener(Event.ADDED_TO_STAGE)) + { + removeEventListener(Event.ADDED_TO_STAGE, init); + } + + initialize(); + + var game:FlxGame = new GameClass(); + addChild(game); + } + + private function initialize():Void + { + Lib.current.stage.align = StageAlign.TOP_LEFT; + Lib.current.stage.scaleMode = StageScaleMode.NO_SCALE; + } +} \ No newline at end of file diff --git a/dominax/source/Player.hx b/dominax/source/Player.hx new file mode 100644 index 0000000..300dea5 --- /dev/null +++ b/dominax/source/Player.hx @@ -0,0 +1,31 @@ +package ; + +import flixel.FlxG; + +/** + * ... + * @author Masadow + */ +class Player +{ + public var name(default, null) : String; + public var id(default, null) : String; + + public static var logged(default, null) : Player = null; + + //Asynchronous call + public static function login(result : Dynamic, done : Void -> Void) + { + trace(result); + if (result != null) + logged = new Player(result.id, result.name); + done(); + } + + private function new(id : String, name : String) + { + this.id = id; + this.name = name; + } + +} \ No newline at end of file diff --git a/dominax/source/state/LoadState.hx b/dominax/source/state/LoadState.hx new file mode 100644 index 0000000..2aca73a --- /dev/null +++ b/dominax/source/state/LoadState.hx @@ -0,0 +1,52 @@ +package state; + +import flixel.FlxSubState; +import flixel.text.FlxText; +import flixel.FlxG; +import flixel.ui.FlxButton; +import haxe.remoting.HttpAsyncConnection; + +/** + * ... + * @author Masadow + */ +class LoadState extends FlxSubState +{ + private var msg : String; + private var cb : Dynamic -> (Void -> Void) -> Void; + private var cmd : String; + private var args : Array; + + public function new(msg : String, cb : Dynamic -> (Void -> Void) -> Void, cmd : String, args : Array) + { + super(); + + this.msg = msg; + this.cb = cb; + this.cmd = cmd; + this.args = args; + } + + override public function create():Void + { + super.create(); + + var txt = new FlxText(0, 350, 640, msg, 24); + txt.alignment = "center"; + add(txt); + + //Prepare the request + var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://" + GameClass.host + "/index.php"); +// var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://haxe/BelugaDemo/bin"); + // setup error handler + cnx.setErrorHandler( function(err) FlxG.log.error(Std.string(err)) ); + cnx.Server.resolve(cmd).call(args, function(v) cb(v, done)); + } + + private function done() + { + trace(GameClass.host); + //Request is done, we can close this state + close(); + } +} diff --git a/dominax/source/state/PlayState.hx b/dominax/source/state/PlayState.hx new file mode 100644 index 0000000..9d4cfb8 --- /dev/null +++ b/dominax/source/state/PlayState.hx @@ -0,0 +1,52 @@ +package state; + +import flash.Lib; +import flixel.FlxCamera; +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.FlxState; +import flixel.FlxObject; +import flixel.text.FlxText; +import openfl.Assets; + +/** + * A FlxState which can be used for the actual gameplay. + */ +class PlayState extends FlxState +{ + /** + * Function that is called up when to state is created to set it up. + */ + override public function create():Void + { + // Set a background color + FlxG.cameras.bgColor = 0xff131c1b; + // Show the mouse (in case it hasn't been disabled) + #if !FLX_NO_MOUSE + FlxG.mouse.visible = true; + #end + + super.create(); + + var loadState = new LoadState("Connecting to the server ...", Player.login, "login", [GameClass.playerId]); + loadState.closeCallback = init; + this.openSubState(loadState); + } + + public function init() + { + if (Player.logged == null) + { + var error = new FlxText(0, 200, 640, "Unable to connect to the server, please make sure you are logged in", 32); + error.alignment = "center"; + add(error); + } + else + add(new FlxText(50, 50, 0, "Welcome " + Player.logged.name, 16)); + } + + override public function update():Void + { + super.update(); + } +} diff --git a/src/Assets.hx b/src/Assets.hx index 2088955..7dd5658 100644 --- a/src/Assets.hx +++ b/src/Assets.hx @@ -64,7 +64,7 @@ class Assets { //Clean assets for (file in FileSystem.readDirectory(dest)) { - if (file.charAt(0) == "." || ["dominax", "lib", "res", "temp"].indexOf(file) >= 0) + if (file.charAt(0) == "." || ["dominax", "lib", "res", "temp", "game"].indexOf(file) >= 0) continue ; if (FileSystem.isDirectory(dest + "/" + file)) deepDelete(dest + "/" + file); diff --git a/src/Main.hx b/src/Main.hx index 90c61bb..79e7005 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -31,15 +31,25 @@ class Main { static function main() { - Assets.build(); - - try { - beluga = Beluga.getInstance(); - Dispatch.run(beluga.getDispatchUri(), Web.getParams(), new Main()); - beluga.cleanup(); - } catch (e : BelugaException) { - trace(e); - } + try { + beluga = Beluga.getInstance(); + //Is it an async request or a user who navigate through the website ? + if (Web.getClientHeader("X_HAXE_REMOTING") == "1") + { + var ctx = new haxe.remoting.Context(); + ctx.addObject("Server",new Server()); + if( haxe.remoting.HttpConnection.handleRequest(ctx) ) + return; + } + else + { + Assets.build(); + Dispatch.run(beluga.getDispatchUri(), Web.getParams(), new Main()); + } + } catch (e : BelugaException) { + trace(e); + } + beluga.cleanup(); } public function new() { diff --git a/src/Server.hx b/src/Server.hx new file mode 100644 index 0000000..61973e6 --- /dev/null +++ b/src/Server.hx @@ -0,0 +1,25 @@ +package ; +import beluga.module.account.Account; +import beluga.core.Beluga; +import haxe.Session; + +/** + * ... + * @author Masadow + */ +class Server +{ + + public function new() + { + } + + public function login(id : String) + { + var acc = Beluga.getInstance().getModuleInstance(Account); + var usr = acc.getUser(Std.parseInt(id)); + return usr != null ? {id: usr.id, name: usr.login} : null; + } + +} + diff --git a/src/game/Game.hx b/src/game/Game.hx index 402fd6f..c4a21c3 100644 --- a/src/game/Game.hx +++ b/src/game/Game.hx @@ -4,6 +4,7 @@ package game; import beluga.core.Beluga; import beluga.core.Widget; import beluga.core.macro.MetadataReader; +import beluga.module.account.Account; // BelugaDemo import main_view.Renderer; @@ -27,7 +28,8 @@ class Game implements MetadataReader { } public function doDefault(d: Dispatch) { - var html = Renderer.renderDefault("game_page", "Dominax", {}); + var user = Beluga.getInstance().getModuleInstance(Account).getLoggedUser(); + var html = Renderer.renderDefault("game_page", "Dominax", {host : Web.getHostName(), user: user}); Sys.print(html); } } \ No newline at end of file diff --git a/src/game/tpl/game_widget.mtt b/src/game/tpl/game_widget.mtt index ffa5078..6692851 100644 --- a/src/game/tpl/game_widget.mtt +++ b/src/game/tpl/game_widget.mtt @@ -1,3 +1,15 @@
-

Your flash game here i think ?

+ + + + +
+ + +
\ No newline at end of file diff --git a/src/main_view/tpl/htmlbody.mtt b/src/main_view/tpl/htmlbody.mtt index 45eaa8c..bfd54fa 100644 --- a/src/main_view/tpl/htmlbody.mtt +++ b/src/main_view/tpl/htmlbody.mtt @@ -24,6 +24,7 @@

You are using an outdated browser. Please upgrade your browser or activate Google Chrome Frame to improve your experience.

+ ::content:: From 3703bec87a7b8c5d7dfd2e497afe5ac0b39a29e1 Mon Sep 17 00:00:00 2001 From: Masadow Date: Wed, 18 Jun 2014 00:06:44 +0200 Subject: [PATCH 3/6] Fix dominax login attempt while not logged in --- dominax/source/Player.hx | 1 - dominax/source/state/LoadState.hx | 1 - src/Server.hx | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dominax/source/Player.hx b/dominax/source/Player.hx index 300dea5..869bbac 100644 --- a/dominax/source/Player.hx +++ b/dominax/source/Player.hx @@ -16,7 +16,6 @@ class Player //Asynchronous call public static function login(result : Dynamic, done : Void -> Void) { - trace(result); if (result != null) logged = new Player(result.id, result.name); done(); diff --git a/dominax/source/state/LoadState.hx b/dominax/source/state/LoadState.hx index 2aca73a..2751dce 100644 --- a/dominax/source/state/LoadState.hx +++ b/dominax/source/state/LoadState.hx @@ -37,7 +37,6 @@ class LoadState extends FlxSubState //Prepare the request var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://" + GameClass.host + "/index.php"); -// var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://haxe/BelugaDemo/bin"); // setup error handler cnx.setErrorHandler( function(err) FlxG.log.error(Std.string(err)) ); cnx.Server.resolve(cmd).call(args, function(v) cb(v, done)); diff --git a/src/Server.hx b/src/Server.hx index 61973e6..ccabd8e 100644 --- a/src/Server.hx +++ b/src/Server.hx @@ -14,10 +14,10 @@ class Server { } - public function login(id : String) + public function login(id : Int) { var acc = Beluga.getInstance().getModuleInstance(Account); - var usr = acc.getUser(Std.parseInt(id)); + var usr = acc.getUser(id); return usr != null ? {id: usr.id, name: usr.login} : null; } From 7e61098f4752c13df188042ff7910a249b658efb Mon Sep 17 00:00:00 2001 From: Masadow Date: Wed, 18 Jun 2014 20:49:15 +0200 Subject: [PATCH 4/6] Fix neko crossdomain --- dominax/source/state/LoadState.hx | 2 +- src/Main.hx | 1 + src/game/Game.hx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dominax/source/state/LoadState.hx b/dominax/source/state/LoadState.hx index 2751dce..35a6027 100644 --- a/dominax/source/state/LoadState.hx +++ b/dominax/source/state/LoadState.hx @@ -36,7 +36,7 @@ class LoadState extends FlxSubState add(txt); //Prepare the request - var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://" + GameClass.host + "/index.php"); + var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://" + GameClass.host + "/"); // setup error handler cnx.setErrorHandler( function(err) FlxG.log.error(Std.string(err)) ); cnx.Server.resolve(cmd).call(args, function(v) cb(v, done)); diff --git a/src/Main.hx b/src/Main.hx index 79e7005..91d5716 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -34,6 +34,7 @@ class Main { try { beluga = Beluga.getInstance(); //Is it an async request or a user who navigate through the website ? + trace("
" + Web.getClientHeaders() + "
"); if (Web.getClientHeader("X_HAXE_REMOTING") == "1") { var ctx = new haxe.remoting.Context(); diff --git a/src/game/Game.hx b/src/game/Game.hx index c4a21c3..2ff2793 100644 --- a/src/game/Game.hx +++ b/src/game/Game.hx @@ -29,7 +29,7 @@ class Game implements MetadataReader { public function doDefault(d: Dispatch) { var user = Beluga.getInstance().getModuleInstance(Account).getLoggedUser(); - var html = Renderer.renderDefault("game_page", "Dominax", {host : Web.getHostName(), user: user}); + var html = Renderer.renderDefault("game_page", "Dominax", {host : Web.getClientHeader("Host"), user: user}); Sys.print(html); } } \ No newline at end of file From 9edf9db2f0455706233b8e56781b5f8ecd4d5a40 Mon Sep 17 00:00:00 2001 From: Masadow Date: Wed, 18 Jun 2014 20:49:58 +0200 Subject: [PATCH 5/6] Remove debug --- src/Main.hx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Main.hx b/src/Main.hx index 91d5716..79e7005 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -34,7 +34,6 @@ class Main { try { beluga = Beluga.getInstance(); //Is it an async request or a user who navigate through the website ? - trace("
" + Web.getClientHeaders() + "
"); if (Web.getClientHeader("X_HAXE_REMOTING") == "1") { var ctx = new haxe.remoting.Context(); From 49ce5819c04b389981f50b67bf5e5ff37e068bd6 Mon Sep 17 00:00:00 2001 From: Masadow Date: Thu, 11 Sep 2014 22:49:38 +0200 Subject: [PATCH 6/6] Dominax update --- assets/.htaccess | 3 + dominax.hxml | 10 ++ dominax/Project.xml | 2 + dominax/assets/images/classic.png | Bin 0 -> 3100 bytes dominax/assets/images/classic.pyxel | Bin 0 -> 10905 bytes dominax/assets/images/classic2.png | Bin 0 -> 3137 bytes dominax/assets/images/classic2.pyxel | Bin 0 -> 12784 bytes dominax/net/ClientApi.hx | 14 ++ dominax/net/IClientApi.hx | 10 ++ dominax/net/IServerApi.hx | 10 ++ dominax/net/Server.hx | 59 ++++++++ dominax/net/ServerApi.hx | 20 +++ dominax/net/ServerCpp.hx | 90 ++++++++++++ src/Server.hx => dominax/net/ServerCppApi.hx | 15 +- dominax/net/XmlPolicyServer.hx | 66 +++++++++ dominax/source/GameClass.hx | 2 +- dominax/source/IPlayer.hx | 15 ++ dominax/source/Player.hx | 66 ++++++++- dominax/source/SocketUtil.hx | 19 +++ dominax/source/game/Domino.hx | 56 ++++++++ dominax/source/game/Grid.hx | 31 ++++ dominax/source/game/Hand.hx | 44 ++++++ dominax/source/ia/Random.hx | 37 +++++ dominax/source/state/LoadState.hx | 59 ++++++-- dominax/source/state/MarketState.hx | 44 ++++++ dominax/source/state/MenuState.hx | 72 ++++++++++ dominax/source/state/PlayState.hx | 104 ++++++++++---- src/HttpServer.hx | 52 +++++++ src/Main.hx | 16 ++- src/game/Game.hx | 2 +- src/services/account/AccountService.hx | 57 +++----- src/services/account/AccountServiceApi.hx | 4 +- src/services/market/MarketService.hx | 30 ++-- src/services/news/NewsService.hx | 133 +++--------------- .../notification/NotificationService.hx | 37 +---- src/services/survey/SurveyService.hx | 80 +++-------- src/services/ticket/TicketService.hx | 23 +-- src/services/wallet/WalletService.hx | 17 +-- 38 files changed, 953 insertions(+), 346 deletions(-) create mode 100644 assets/.htaccess create mode 100644 dominax/assets/images/classic.png create mode 100644 dominax/assets/images/classic.pyxel create mode 100644 dominax/assets/images/classic2.png create mode 100644 dominax/assets/images/classic2.pyxel create mode 100644 dominax/net/ClientApi.hx create mode 100644 dominax/net/IClientApi.hx create mode 100644 dominax/net/IServerApi.hx create mode 100644 dominax/net/Server.hx create mode 100644 dominax/net/ServerApi.hx create mode 100644 dominax/net/ServerCpp.hx rename src/Server.hx => dominax/net/ServerCppApi.hx (72%) create mode 100644 dominax/net/XmlPolicyServer.hx create mode 100644 dominax/source/IPlayer.hx create mode 100644 dominax/source/SocketUtil.hx create mode 100644 dominax/source/game/Domino.hx create mode 100644 dominax/source/game/Grid.hx create mode 100644 dominax/source/game/Hand.hx create mode 100644 dominax/source/ia/Random.hx create mode 100644 dominax/source/state/MarketState.hx create mode 100644 dominax/source/state/MenuState.hx create mode 100644 src/HttpServer.hx diff --git a/assets/.htaccess b/assets/.htaccess new file mode 100644 index 0000000..9c1e95d --- /dev/null +++ b/assets/.htaccess @@ -0,0 +1,3 @@ +RewriteEngine on +RewriteCond $1 !^(index\.php|css|img|js|game|robots\.txt) +RewriteRule ^(.*)$ /Dominax/bin/php/index.php/$1 [L] \ No newline at end of file diff --git a/dominax.hxml b/dominax.hxml index 588449d..9f646ae 100644 --- a/dominax.hxml +++ b/dominax.hxml @@ -15,3 +15,13 @@ -neko bin/neko/index.n -main Main -D target=neko + +--next + +-cp dominax +-lib session +-lib beluga +-lib tink_macro +-neko bin/server.n +-main net.Server +-D target=neko diff --git a/dominax/Project.xml b/dominax/Project.xml index 172d84c..6d2ea84 100644 --- a/dominax/Project.xml +++ b/dominax/Project.xml @@ -15,6 +15,8 @@ + + diff --git a/dominax/assets/images/classic.png b/dominax/assets/images/classic.png new file mode 100644 index 0000000000000000000000000000000000000000..fa02efeca0628a73e9abe186bf6fbfb5b0a47008 GIT binary patch literal 3100 zcmd6p=|7ZvAIIk!gBi;)MxoM-$;hG9NJwJF5++W_zHeDusGM6FahWr@RgSTz#d2~g z$684$;Yu+PN@ZVWY7`~LBx5jU?#p?-&i&;62ks}o>-*sSd-AANlL5NOW=8plpgx4>DePx}q1NAUU(WYVmxOsI;~}sRV%v zxQT3W(&L=xY?9nL)=)xNl>L##sh9A_WO~XW*bHa<8F#Eej=YSmlmmYo9JwNAjze2sRV7N>H^c`2=uj@XT9q4UynSlksUKf z^%OC`xP1;p9cc1NrUQvi47)|BCT8x?JFMm0J1^v%sob^@iIFy7=3;}k=5u}n?6G7u`|-7Qh&H=5>NshTDnCJIPK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IZoD3Uhdt>y|xeIr9Iz05aPJC~eGj>sdI)4^$cbVumsw!JUPm;OxR zUyN51tkdr4Wy71l9S7=m6^!~p#kOxUX+`*miGxu6<@QF6_(qbWhsxNs&$WA%`*>C- zbh#(PwUM6*GPw8!5)=DFVp+6C-36HSAiWN^1)P|6qtH%y+90pVL4^F@d?N5gplDQp zsQ^Cm)LTKj~8V3$*Td`W__iZmfzUl^DHz4w^O!8Nt4nBUmz4BP0L(=9_-F z4xXdK5`B*?RE0~@9+Y|P)FWemn914XSDh`R4XbNSjjR`pO9xRe*c@Mo;9y5gc_t8C z{=0zu2~re|%C#xxtUEG<);&@uYx`zA;iqJAmzd3K%|Sts>V+OW5;y;7?P^jAaHCl=e(aXU-NoyX?O0cIQu4C2(CAau z8ShbdzR@fWDf~L;{WXmgn$>8z1HkMHgkr?O8%Gbl~=lh zVK_2@vT~{{lj5Xl$SuCW^~dP8 zZPi5XfW_np!Bw4H59$gt8Y$XI>nww*8CpORKvIwiuPeG&j?_ z7@MkZ8a3<*O~-)Mqj?c(GC!;TcrBb{9Bh|=_mLZ)Ef+rG7u zZtQ#|6aR9NI(K9N%u)N0n6Bd4&nLVS%7geV(oAn$h|}Bx+xVUqH$c tNUE`}bzQjT!MOkc literal 0 HcmV?d00001 diff --git a/dominax/assets/images/classic.pyxel b/dominax/assets/images/classic.pyxel new file mode 100644 index 0000000000000000000000000000000000000000..0aeefa373fd9f628696766bdefa2e6da2e88100a GIT binary patch literal 10905 zcmdU#c{CJk*v7|B)>0UIrB|}=`xa7UNw$cw@3M@2mq@8BiDYX-cCr&gvPH-?_I-<( zL5vy9e4|&d-g$G5^ZoOkkMmg0oZp%ATyxKJUHAQrwmJdfX#jwf6u?t*QDx)g;2j-8 z0DzhV05|~v0G!Nyt=$FqT<_Q}Q^3Isb8*uaW@eL{KU~T1d#D*07=RLkA$fZ4dQc$4 zV1aM7M1=0BpTBrDtT+ka7*f};niQPMlFa=0L=d;vmZP&&%QiPMbo7UDVtIjKyd|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1K?VR8L?|%SVzCV%x literal 0 HcmV?d00001 diff --git a/dominax/assets/images/classic2.png b/dominax/assets/images/classic2.png new file mode 100644 index 0000000000000000000000000000000000000000..6fc0222733a725e8c3ab8cb11afe44591fccaec6 GIT binary patch literal 3137 zcmdUy`#V(o9>-@bGtH$i7}B;i;}(--+U=5@8B_j?sli z#B?F0WQUZ($|jY`rIcJ}q8Lf;j2bg%)qc*i&-0vr;GCb;r#}a9pM;gZQ z3~`KjKh@mS_#vV~ku|ps#fT@VQ`hHKe(LY{kZ{46>WV>WYJAU}rHrJ!Gx~racNl&6 zXU!M?+jsOJ$SnsdlC7NYF;?N;_0AW+Pq{KPUsZ$Z%}`VrMAdOZJplZ11MHXUOLqxH zl^;tFQ91h$lsgfuFmyipSYyt_>+pPVD)-e&6V3~}uOF#mQ_0-K&5cYj2`@UNwcBhF zkS})fZjrF8z-_w)`{z-&hx~>`*TiVv^7w4bkB4_0oI`m`Oau6JG*#NNnrG=QZov<9E>AoS9nrKyPReQ~*Hnkdb4ot{hS7uUXl9s!5Iv`psw>Jdv zuJAK-&MM3$8%~}<$~c+Dy!9qL3Wemg*1IGun&sRDQ)fyv{6 zef_pJoM$(GySM|-T{fvuWKT9O@SPmZjHK|CFXp_7JYMv-*VY3H1-h=mQmjX;B1u#b z+C3J$ve>D4#wdD>ddJMM+y*1Dq%5LqE}bn<%_4m zd(Z7!2e}y0AGj;H$pP5`yth^RWrIQkAY`;i zpD>Hgj9LFkcC?q`;RYdT?D)qc%KVML3x(G{~R4eDngHOpko>E)Z+VC(z z)_?tjBM`p^=`c@?boa0lrsm{1^oDDZ=vXrf5|J!ub%D4P z^XV0sxiX{655B~1S&~AdKY5e_aTljV+R7qW>4nx&;aLuBqbnaW&F$V-B6J%o(A|%4 zCYUPn`&PU6x=~I*>EfU*8uX86Ncplg9eOO^y_(|`ug>VWd44@ZKrYD ztu6OgXEiiPv-sz=?hZ(8q)dgvVKQH=Pz*o_=tse^ar`Nv2h&oP8b}D?Gr4n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js}|H@edTeQPcxkdE0dun!E_fpdjvKy2fCG3_Ca0c=4h3AKC zWKC3gDoeEVmtGe9Fr~g?aa4t=Yn%T4a>=C|nyp9N&Ke!*Nq2*_cwj_;AU&~HdqQq> z1b_cB)R98VPgpwbn(U3o7ivO|g$w?0C+|YZMxR)UQ3%Y4r(S}Yx7HW>W<-VlBox-H zsrj4vi?*1@|Hb^c+v872xXUalF{`EyYVWHoRULU&E<)!B$#D)XsX~iXgOU&v#ZEA! z6Z!h~yrFZ%tHC#~^W5;F!_fv*xdQc>D!VtU5z?FMt`njORP>s(t04On&mx>CSa=+X zQ`9EF|2C-ATX~Q#nOYw&KeD*<) zO-wMP3e@!^T&&hMq+@f|V#*znZJ`Iwq_?P`PGTqV3v|!YjI-z6pIZz;tq=am$85)t zbY>t`gI{dD1Sj;nby(?TT&KO(wfBvO*6aT>Oyhikgo^17(sG6;=49-^H*^bgv5WVL z9<0PuV9KEc>LfwPX;110I|`uiDnq3`kU!T39o07bNg!bS7y@uZexYw cv_g%U-f<`G_r`n?@@s(F%-ZH$ypfamFVS|)r~m)} literal 0 HcmV?d00001 diff --git a/dominax/assets/images/classic2.pyxel b/dominax/assets/images/classic2.pyxel new file mode 100644 index 0000000000000000000000000000000000000000..94a4378e82671b60505a013bc3e0665c620016c4 GIT binary patch literal 12784 zcmdU#WmJ@H+qQ@9MnXc6mKs1&xuJ6ygURW11tZQvQ&V7zK_x(7|>#+<1A|U{PiVDasW0Z&`eQj-q0RRYN0s!a$ z0Km%7&BPwaX8X)+B<`F~<(#t3jFqb=emVe6!c-@inpFFxm9b7%P#EJYw)aQQ9RiyI zM)493ovk9ox0heH(n(m~K7K=iUzw3_-(h9X;L-zZ)jVu+>)lTVUBH1pl#cG7798@g zU%GkD&K)1Sn6)(xo=~_FqSINMSuXkMoH7#nG+K*nQRYfiOTEh|a^{Y0YdkkaK`D$- zAz0Dt@%~(}yDV-DC!$5sbF0c*;4-IoWF;Vfg{f$IZ)Y!Xo%l(o*P|HBd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nq_ZqsST7FHef4*?CTCSyxTY@^eA!0%REQW@Rz zt3@8Nxpnjn65ML3u6LSQbf|7TQ4*YmKFi1San{im4Bkobei;=YU(aqC1msoJ)KLIh zxNjOH^a^E}=`EKO3YS4p)(w)p+CGTp)RB1wuU>|ff;04%-_$ zY;y)^F!*eu7WD$AsQV4)oG~58%P9~kj;y6boX*Cv{nsvvDNsfzgg5!Kx8S}+No__v z`>J^Up3IH>qIAFBzs{Lb!-Wa@?u){zB;~eeV#Cl)QT{p(&?>b8YXxX^Uj&Z8t!!qy z3AGABKc_&dDNg@BVu+}4tX-QuZgY>jj*2eys}qh1n@LW3nP~v0kH($P53o!IfwH{{ zc%9N6N=xEVnXL9CM8ph?VtxynWQ&>8wNa&$B9%v)H`nnE!gj740B&dU3^3#UPi-sYSNpf z{iqWe8C!(7*l9|{I*kyaMf(^~ODdBMwnbs;xBHgUeSPeaWv3O#!r&>7ON7TVaPWix z!aqJ!3oWc)ey*Reh2>xm|F5A4=o7mCJ_-Pf!5)@hW3kYh{yy%#8iK=Ou&2z|SPa%b z*!Oq^i@_eqUSnz4|6tz}2`mPCnt6>S;{1bs_iI=T_Q3BNE5Q8+`)+Ws80@LnH8zj; z5B7cUhs9vel&-N#{C}|Tdmk(Yd-`&XwG#Y;eeZi=G1%jZYpfeuOIM%U_ihjtgPrGJ zV~aQb!Ty=`_2w}k>b6ussoNPlp@trXZn<2A>0 z^9T3aQh}YxU31)IKe*r43hWT;niC-Z!Tq*aV8=YyoHE4^?zhzfI~cjjgG0Uvph_Ke*r43v86U=0Nm6xZleinzpWS8 fjB?F^q1>;D<*^LX)sqeYO6YG8^qms()qnpFZ-MFI literal 0 HcmV?d00001 diff --git a/dominax/net/ClientApi.hx b/dominax/net/ClientApi.hx new file mode 100644 index 0000000..305304f --- /dev/null +++ b/dominax/net/ClientApi.hx @@ -0,0 +1,14 @@ +package net; + +/** + * ... + * @author Masadow + */ +class ClientApi implements IClientApi +{ + public function new () { } + + public function logged() { +// display("User join "+name+""); + } +} diff --git a/dominax/net/IClientApi.hx b/dominax/net/IClientApi.hx new file mode 100644 index 0000000..0c11003 --- /dev/null +++ b/dominax/net/IClientApi.hx @@ -0,0 +1,10 @@ +package net; + +/** + * ... + * @author Masadow + */ +interface IClientApi +{ + public function logged() : Void; +} \ No newline at end of file diff --git a/dominax/net/IServerApi.hx b/dominax/net/IServerApi.hx new file mode 100644 index 0000000..c467dd4 --- /dev/null +++ b/dominax/net/IServerApi.hx @@ -0,0 +1,10 @@ +package net; + +/** + * ... + * @author Masadow + */ +interface IServerApi +{ + public function login(id : Int) : { id : Int, name : String }; +} \ No newline at end of file diff --git a/dominax/net/Server.hx b/dominax/net/Server.hx new file mode 100644 index 0000000..54c2f09 --- /dev/null +++ b/dominax/net/Server.hx @@ -0,0 +1,59 @@ +package net; + +/** + * ... + * @author Masadow + */ +// define a typed remoting API +class ClientApiImpl extends haxe.remoting.AsyncProxy { +} + +// our client class +class ClientData extends ServerApi { + + var api : ClientApiImpl; + var name : String; + + public function new( scnx : haxe.remoting.SocketConnection ) { + api = new ClientApiImpl(scnx.client); + (cast scnx).__private = this; + } + + public function leave() { + Server.clients.remove(this); + } + + public static function ofConnection( scnx : haxe.remoting.SocketConnection ) : ClientData { + return (cast scnx).__private; + } + +} + +// server loop + +class Server { + + public static var clients = new List(); + + static function initClientApi( scnx : haxe.remoting.SocketConnection, context : haxe.remoting.Context ) { + trace("Client connected"); + scnx.setErrorHandler(function (error) { trace(error); } ); + var c = new ClientData(scnx); + context.addObject("api", c); + } + + static function onClientDisconnected( scnx ) { + trace("Client disconnected"); + ClientData.ofConnection(scnx).leave(); + } + + static function main() { + var host = "localhost"; + var domains = [host]; + var s = new neko.net.ThreadRemotingServer(domains); + s.initClientApi = initClientApi; + s.clientDisconnected = onClientDisconnected; + trace("Starting server..."); + s.run(host,3000); + } +} diff --git a/dominax/net/ServerApi.hx b/dominax/net/ServerApi.hx new file mode 100644 index 0000000..2887232 --- /dev/null +++ b/dominax/net/ServerApi.hx @@ -0,0 +1,20 @@ +package net; + +import beluga.core.Beluga; +import beluga.module.account.Account; + +/** + * ... + * @author Masadow + */ +class ServerApi implements IServerApi +{ + public function login(id : Int) + { + Sys.println("Login attempt"); + var acc = Beluga.getInstance().getModuleInstance(Account); + var usr = acc.getUser(id); + Sys.println("Return " + (usr != null ? usr.login : "null")); + return usr != null ? {id: usr.id, name: usr.login} : null; + } +} \ No newline at end of file diff --git a/dominax/net/ServerCpp.hx b/dominax/net/ServerCpp.hx new file mode 100644 index 0000000..345b841 --- /dev/null +++ b/dominax/net/ServerCpp.hx @@ -0,0 +1,90 @@ +package ; +import haxe.ds.StringMap.StringMap; +import haxe.remoting.SocketProtocol.Socket; +#if (php || neko) +import haxe.Session; +#end +import sys.net.Host; +import haxe.web.Dispatch; + +/** + * ... + * @author Masadow + */ +class Server +{ + + public function new() + { + } + + public static function main() + { + var host : String = "localhost"; + var port : String = "3000"; + var args : Array = Sys.args(); + if (args.length == 2) { + host = args[0]; + port = args[1]; + } + + var ctx = new haxe.remoting.Context(); + ctx.addObject("Server", new ServerCppApi()); + var server = new Socket(); + server.bind(new Host(host), Std.parseInt(port)); + server.listen(100); + var policyserver = new XmlPolicyServer(host); + var clients : Array = [server, policyserver.socket]; + + Sys.println("Server running on " + host + ":" + port); + while (true) + { + for (socket in Socket.select(clients, [], []).read) //Retrieve ready sockets to read + { + trace("Incomming request"); +// if ((untyped socket.__client) == null) + if (socket == server) + { + trace("Incomming connection"); + //Incomming connection + var s = server.accept(); + clients.push(s); +// var response = '\x00'; +// s.write(response); + s.output.writeByte(1); + trace("Client connected"); + } + else if (socket == policyserver.socket) + { + policyserver.update(); + } + else + { + trace("Incomming message"); + //Receiving client request + try { + var l = socket.input.readLine(); + trace("Data : " + l); + var nparams = Std.parseInt(l); + Sys.println("params : " + nparams); + var request = socket.input.readLine(); + var params = new StringMap(); + for (i in 0...nparams) + params.set("" + i, socket.input.readLine()); + Dispatch.run(request, params, new ServerCppApi()); + } + catch (e : Dynamic) + { + //Close socket + clients.remove(socket); + socket.close(); + trace("Client disconnected"); + } + trace("Message treated"); + } + } +// client = server.accept(); + } +// socket. + } +} diff --git a/src/Server.hx b/dominax/net/ServerCppApi.hx similarity index 72% rename from src/Server.hx rename to dominax/net/ServerCppApi.hx index ccabd8e..59e5654 100644 --- a/src/Server.hx +++ b/dominax/net/ServerCppApi.hx @@ -1,25 +1,26 @@ package ; + import beluga.module.account.Account; import beluga.core.Beluga; -import haxe.Session; +import haxe.web.Dispatch; /** * ... * @author Masadow */ -class Server +class ServerCppApi { - + public function new() { } - - public function login(id : Int) + + public function doLogin(id : Int) { + Sys.println("Login attempt"); var acc = Beluga.getInstance().getModuleInstance(Account); var usr = acc.getUser(id); return usr != null ? {id: usr.id, name: usr.login} : null; } -} - +} \ No newline at end of file diff --git a/dominax/net/XmlPolicyServer.hx b/dominax/net/XmlPolicyServer.hx new file mode 100644 index 0000000..dca9511 --- /dev/null +++ b/dominax/net/XmlPolicyServer.hx @@ -0,0 +1,66 @@ +package ; + +import sys.net.Socket; +import sys.net.Host; +import haxe.io.Bytes; +/** + * Compiled separatly under neko. + */ + +class XmlPolicyServer { + public var socket : Socket; + + public function new(host : String) { + socket = new Socket(); + try{ + socket.bind( new Host( host ), 843 ); + + socket.listen( 10 ); + } + catch (z:Dynamic) { + Sys.stdout().writeString("Server Start Failed. \n"); + return; + } + Sys.println("Policy server running on " + host + ":843"); + //while (true) { + //} + } + + public function update() + { + trace("Receive policy request"); + var cnx = socket.accept(); + var tbuf = Bytes.alloc(30); + var cont = true; + var msg : String = ''; + while (cont) + { + try + { + cnx.waitForRead(); + var len = cnx.input.readBytes(tbuf, 0, 30); + msg += tbuf.toString().substr(0, len); + cont = msg.indexOf('\x00') < 0; // read up to null byte + } + catch (e : Dynamic) + { + + var x = Std.string(e); + if (x != 'Eof') + { + trace('Error: $x'); + } + cont = false; + + } + } + var msg_cut = msg.substr(1, 6); + + if ( msg_cut == 'policy' ) { + var response = '\x00'; + cnx.write(response); + trace("Allow policy"); + } + cnx.shutdown(true, true); + } +} \ No newline at end of file diff --git a/dominax/source/GameClass.hx b/dominax/source/GameClass.hx index 1933d92..3e54f5b 100644 --- a/dominax/source/GameClass.hx +++ b/dominax/source/GameClass.hx @@ -22,6 +22,6 @@ class GameClass extends FlxGame host = Lib.current.loaderInfo.parameters.host; playerId = Std.parseInt(Lib.current.loaderInfo.parameters.uid); - super(Math.ceil(stageWidth / ratio), Math.ceil(stageHeight / ratio), state.PlayState, ratio, fps, fps); + super(Math.ceil(stageWidth / ratio), Math.ceil(stageHeight / ratio), state.MenuState, ratio, fps, fps); } } diff --git a/dominax/source/IPlayer.hx b/dominax/source/IPlayer.hx new file mode 100644 index 0000000..8944228 --- /dev/null +++ b/dominax/source/IPlayer.hx @@ -0,0 +1,15 @@ +package ; +import game.Hand; +import game.Domino; +import state.PlayState; + +/** + * ... + * @author Masadow + */ +interface IPlayer +{ + public function getHand() : Hand; + public function getScore() : Int; + public function play(game : PlayState) : Void; +} diff --git a/dominax/source/Player.hx b/dominax/source/Player.hx index 869bbac..fd0dbdb 100644 --- a/dominax/source/Player.hx +++ b/dominax/source/Player.hx @@ -1,30 +1,90 @@ package ; import flixel.FlxG; +import game.Domino; +import game.Hand; +import state.PlayState; /** * ... * @author Masadow */ -class Player +class Player implements IPlayer { public var name(default, null) : String; public var id(default, null) : String; public static var logged(default, null) : Player = null; + // in game vars + private var hand : Hand; + private var score : Int; + private var select : Domino; + //Asynchronous call - public static function login(result : Dynamic, done : Void -> Void) + public static function login(result : Dynamic) { if (result != null) logged = new Player(result.id, result.name); - done(); } private function new(id : String, name : String) { this.id = id; this.name = name; + + hand = new Hand(); + score = 0; + } + + //IPlayer implements + + public function getHand() : Hand + { + return hand; + } + + public function getScore() : Int + { + return score; + } + + public function play(game : PlayState) + { + var mouse = FlxG.mouse.cursorContainer; + var unselect = FlxG.mouse.justPressed; + game.cursor.visible = false; + for (domino in hand) + { + if (mouse.x > domino.x && mouse.x < domino.x + domino.width + && mouse.y > domino.y && mouse.y < domino.y + domino.height) + { + game.cursor.x = domino.x; + game.cursor.y = domino.y; + game.cursor.visible = true; + unselect = false; + if (FlxG.mouse.justPressed) + { + if (select == domino) + { //Unselect + select = null; + game.select.visible = false; + } + else + { + select = domino; + game.select.x = domino.x; + game.select.y = domino.y; + game.select.visible = true; + } + } + } + } + if (unselect) + { + select = null; + game.select.visible = false; + } } } \ No newline at end of file diff --git a/dominax/source/SocketUtil.hx b/dominax/source/SocketUtil.hx new file mode 100644 index 0000000..09166c5 --- /dev/null +++ b/dominax/source/SocketUtil.hx @@ -0,0 +1,19 @@ +package ; +import flash.net.Socket; + +/** + * ... + * @author Masadow + */ +class SocketUtil +{ + public static function sendRequest(socket : Socket, request : String, args : Array) + { + socket.writeObject(args.length + "\n"); + socket.writeObject(request + "\n"); + for (arg in args) + socket.writeObject(arg + "\n"); + socket.flush(); + } + +} \ No newline at end of file diff --git a/dominax/source/game/Domino.hx b/dominax/source/game/Domino.hx new file mode 100644 index 0000000..02a7769 --- /dev/null +++ b/dominax/source/game/Domino.hx @@ -0,0 +1,56 @@ +package game; +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.math.FlxRandom; + +enum DominoColor +{ + BLACK; + RED; + GREEN; + BLUE; +} + +/** + * ... + * @author Masadow + */ +class Domino extends FlxSprite +{ + //Determine the number of occurence of a exact same domino inside the stack + private static var COPIES : Int = 2; + + private var dominoColor : DominoColor; + private var value : Int; + + public static function makeStack() : Array + { + var stack : Array = []; + var colors = DominoColor.createAll(); + for (v in 1...8) + { + for (c in colors) + { + for (i in 0...COPIES) + { + stack.push(new Domino(c, v)); + } + } + } + //Don't forget to shuffle the stack + return FlxG.random.shuffleArray(stack, stack.length * 8); + } + + public function new(c : DominoColor, v : Int) + { + super(); + + dominoColor = c; + value = v; + + //Make sprite + this.loadGraphic("images/classic.png", false, 32, 64, true); + this.animation.frameIndex = v - 1 + 7 * c.getIndex(); + } + +} \ No newline at end of file diff --git a/dominax/source/game/Grid.hx b/dominax/source/game/Grid.hx new file mode 100644 index 0000000..a291686 --- /dev/null +++ b/dominax/source/game/Grid.hx @@ -0,0 +1,31 @@ +package game; +import flixel.FlxSprite; +import flixel.util.FlxColor; +import flixel.util.FlxSpriteUtil; + +/** + * ... + * @author Masadow + */ +class Grid extends FlxSprite +{ + private inline static var WIDTH = 24; + private inline static var HEIGHT = 20; + + public function new(x : Int, y : Int) + { + super(x, y); + + makeGraphic(WIDTH * 16 + 1, HEIGHT * 16 + 1, FlxColor.GRAY); + + FlxSpriteUtil.setLineStyle( { color: FlxColor.WHITE } ); + for (y in 0...HEIGHT + 1) + { + FlxSpriteUtil.drawLine(this, 0, y * 16, WIDTH * 16, y * 16); + } + for (x in 0...WIDTH + 1) + { + FlxSpriteUtil.drawLine(this, x * 16, 0, x * 16, HEIGHT * 16); + } + } +} \ No newline at end of file diff --git a/dominax/source/game/Hand.hx b/dominax/source/game/Hand.hx new file mode 100644 index 0000000..db5eafe --- /dev/null +++ b/dominax/source/game/Hand.hx @@ -0,0 +1,44 @@ +package game; +import flixel.FlxG; + +/** + * ... + * @author Masadow + */ +class Hand +{ + private var dominos : Array; + + public function new() + { + dominos = []; + } + + public function takeDomino(d : Domino) : Void + { + dominos.push(d); + } + + public function size() + { + return dominos.length; + } + + public function draw() + { + var x = 50; + for (domino in dominos) + { + domino.y = FlxG.height - 64; + domino.x = x; + x += 32; + domino.draw(); + } + } + + public function iterator() : Iterator + { + return dominos.iterator(); + } + +} \ No newline at end of file diff --git a/dominax/source/ia/Random.hx b/dominax/source/ia/Random.hx new file mode 100644 index 0000000..07936a4 --- /dev/null +++ b/dominax/source/ia/Random.hx @@ -0,0 +1,37 @@ +package ia; +import game.Hand; +import state.PlayState; + +/** + * ... + * @author Masadow + */ +class Random implements IPlayer +{ + + private var hand : Hand; + private var score : Int; + + public function new() + { + hand = new Hand(); + score = 0; + } + + // IPlayer + public function getHand() : Hand + { + return hand; + } + + public function getScore() : Int + { + return score; + } + + public function play(game : PlayState) : Void + { + + } + +} \ No newline at end of file diff --git a/dominax/source/state/LoadState.hx b/dominax/source/state/LoadState.hx index 35a6027..28c055e 100644 --- a/dominax/source/state/LoadState.hx +++ b/dominax/source/state/LoadState.hx @@ -5,19 +5,34 @@ import flixel.text.FlxText; import flixel.FlxG; import flixel.ui.FlxButton; import haxe.remoting.HttpAsyncConnection; +import haxe.remoting.SocketConnection; +import state.LoadState.ServerApiImpl; +//import haxe.remoting.SocketProtocol.Socket; +import flash.net.Socket; +import net.ClientApi; + +using SocketUtil; + +class ServerApiImpl extends haxe.remoting.AsyncProxy { +} /** - * ... + * Execute a query to the game server * @author Masadow */ class LoadState extends FlxSubState { + private static var socket : flash.net.XMLSocket = null; + private static var scnx : SocketConnection; + private static var server : ServerApiImpl; + private var msg : String; - private var cb : Dynamic -> (Void -> Void) -> Void; + private var cb : Dynamic -> Void; private var cmd : String; private var args : Array; + private var htmlRequest : Bool; - public function new(msg : String, cb : Dynamic -> (Void -> Void) -> Void, cmd : String, args : Array) + public function new(msg : String, cb : Dynamic -> Void, cmd : String, args : Array, htmlRequest : Bool = true) { super(); @@ -25,6 +40,7 @@ class LoadState extends FlxSubState this.cb = cb; this.cmd = cmd; this.args = args; + this.htmlRequest = htmlRequest; } override public function create():Void @@ -35,16 +51,41 @@ class LoadState extends FlxSubState txt.alignment = "center"; add(txt); - //Prepare the request - var cnx = haxe.remoting.HttpAsyncConnection.urlConnect("http://" + GameClass.host + "/"); - // setup error handler - cnx.setErrorHandler( function(err) FlxG.log.error(Std.string(err)) ); - cnx.Server.resolve(cmd).call(args, function(v) cb(v, done)); + if (htmlRequest) + { + var cnx = HttpAsyncConnection.urlConnect("http://" + GameClass.host + "/"); + cnx.setErrorHandler( function(err) FlxG.log.error(Std.string(err)) ); + cnx.Server.resolve(cmd).call(args, function(v) { cb(v); done(); } ); + } + else + { + //Prepare socket if needed + if (socket == null) + { + FlxG.log.add("Init socket"); + socket = new flash.net.XMLSocket(); + socket.addEventListener(flash.events.Event.CONNECT, send); + socket.connect("localhost",3000); + var context = new haxe.remoting.Context(); + context.addObject("client", new ClientApi()); + scnx = haxe.remoting.SocketConnection.create(socket,context); + scnx.setErrorHandler( function(err) FlxG.log.error(Std.string(err)) ); + context.addObject("server", new ServerApiImpl(scnx.api)); + } + else { + send(null); + } + } + } + + public function send(event:flash.events.Event) + { //socket only + FlxG.log.add("Send request"); + scnx.api.resolve(cmd).call(args, function(v) { cb(v); done(); } ); } private function done() { - trace(GameClass.host); //Request is done, we can close this state close(); } diff --git a/dominax/source/state/MarketState.hx b/dominax/source/state/MarketState.hx new file mode 100644 index 0000000..afc30ad --- /dev/null +++ b/dominax/source/state/MarketState.hx @@ -0,0 +1,44 @@ +package state; +import flixel.FlxG; +import flixel.FlxSubState; +import flixel.text.FlxText; +import flixel.ui.FlxButton; + +/** + * ... + * @author Masadow + */ +class MarketState extends FlxSubState +{ + + var money : FlxText; + + override public function create():Void + { + super.create(); + + this.bgColor = _parentState.bgColor; + + money = new FlxText(20, 20, 0, "", 16); + + var loadState = new LoadState("Looking for the market ...", applyMarket, "getMarket", [GameClass.playerId]); + loadState.closeCallback = init; + this.openSubState(loadState); + } + + public function applyMarket(result : Dynamic) + { + money.text = "You have " + result.fund + " " + result.currency; + for (product in cast(result.products, List)) + { + FlxG.log.add(product.name); + } + } + + public function init() + { + add(money); + add(new FlxButton(50, 400, "Back to menu", close)); + } + +} \ No newline at end of file diff --git a/dominax/source/state/MenuState.hx b/dominax/source/state/MenuState.hx new file mode 100644 index 0000000..32501ad --- /dev/null +++ b/dominax/source/state/MenuState.hx @@ -0,0 +1,72 @@ +package state; + +import flash.Lib; +import flixel.FlxCamera; +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.FlxState; +import flixel.FlxObject; +import flixel.text.FlxText; +import flixel.ui.FlxButton; +import game.Domino; +import openfl.Assets; + +/** + * A FlxState which can be used for the actual gameplay. + */ +class MenuState extends FlxState +{ + /** + * Function that is called up when to state is created to set it up. + */ + override public function create():Void + { + // Set a background color + FlxG.cameras.bgColor = 0xff131c1b; + // Show the mouse (in case it hasn't been disabled) + #if !FLX_NO_MOUSE + FlxG.mouse.visible = true; + #end + + super.create(); + + var loadState = new LoadState("Connecting to the server ...", Player.login, "login", [GameClass.playerId]); + loadState.closeCallback = init; + this.openSubState(loadState); + + //Load menu + var joinBtn = new FlxButton(50, 400, "Join a game !", join); + } + + public function init() + { + if (Player.logged == null) + { + var error = new FlxText(0, 200, 640, "Unable to connect to the server, please make sure you are logged in", 32); + error.alignment = "center"; + add(error); + } + else + { + add(new FlxText(50, 50, 0, "Welcome " + Player.logged.name, 16)); + add(new FlxButton(100, 400, "Play !", function () FlxG.switchState(new PlayState()))); + add(new FlxButton(200, 400, "Market", function () this.openSubState(new MarketState()))); + } + } + + override public function update(elapsed:Float):Void + { + super.update(elapsed); + } + + public function join():Void + { + var joinState = new LoadState("Finding a partner ...", found, "searchGamePartner", [GameClass.playerId]); + this.openSubState(joinState); + } + + public function found(result : Dynamic):Void + { + FlxG.log.add(result); + } +} diff --git a/dominax/source/state/PlayState.hx b/dominax/source/state/PlayState.hx index 9d4cfb8..5a6b69c 100644 --- a/dominax/source/state/PlayState.hx +++ b/dominax/source/state/PlayState.hx @@ -1,52 +1,100 @@ package state; - -import flash.Lib; -import flixel.FlxCamera; +import flash.text.GridFitType; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxState; -import flixel.FlxObject; import flixel.text.FlxText; -import openfl.Assets; +import flixel.util.FlxColor; +import ia.Random; +import game.Domino; +import game.Grid; /** - * A FlxState which can be used for the actual gameplay. + * ... + * @author Masadow */ class PlayState extends FlxState { - /** - * Function that is called up when to state is created to set it up. - */ + public var cursor : FlxSprite; + public var select : FlxSprite; + + private var turn : Null; + private var computer : Random; + private var human : Player; + private var stack : Array; + + //texts + private var txtScoreHuman : FlxText; + private var txtScoreComputer : FlxText; + private var txtTurn : FlxText; + override public function create():Void { - // Set a background color - FlxG.cameras.bgColor = 0xff131c1b; - // Show the mouse (in case it hasn't been disabled) - #if !FLX_NO_MOUSE - FlxG.mouse.visible = true; - #end - super.create(); + + bgColor = FlxColor.GRAY; + + add(new Grid(120, 80)); + + cursor = new FlxSprite(); + cursor.visible = false; + cursor.makeGraphic(32, 64, FlxColor.fromRGB(100, 100, 100, 100)); + + select = new FlxSprite(); + select.visible = false; + select.makeGraphic(32, 64, FlxColor.fromRGB(70, 70, 70, 100)); + + computer = new Random(); + human = Player.logged; + turn = null; //Not started yet - var loadState = new LoadState("Connecting to the server ...", Player.login, "login", [GameClass.playerId]); - loadState.closeCallback = init; - this.openSubState(loadState); + stack = Domino.makeStack(); + + add(txtScoreComputer = new FlxText(10, 10)); + add(txtScoreHuman = new FlxText(10, 20)); + add(txtTurn = new FlxText(150, 10, 0, "", 32)); } - public function init() + override public function update(elapsed:Float):Void { - if (Player.logged == null) + super.update(elapsed); + + //Init the game + if (turn == null) { - var error = new FlxText(0, 200, 640, "Unable to connect to the server, please make sure you are logged in", 32); - error.alignment = "center"; - add(error); + fillHand(human); + fillHand(computer); + //Randomly determine the starting player + turn = FlxG.random.bool() ? human : computer; + turn = human; //TEMP ! + txtTurn.text = turn == human ? "It's your turn !" : "Wait for your opponent..."; } - else - add(new FlxText(50, 50, 0, "Welcome " + Player.logged.name, 16)); + //Let's play the current turn + turn.play(this); + //Update the displayed score + txtScoreComputer.text = "Computer : " + computer.getScore(); + txtScoreHuman.text = "Human : " + human.getScore(); } - override public function update():Void + override public function draw():Void { - super.update(); + super.draw(); + + human.getHand().draw(); + + if (cursor.visible) + cursor.draw(); + + if (select.visible) + select.draw(); + } + + private function fillHand(p : IPlayer) + { //Draw up to 5 cards + var hand = p.getHand(); + while (hand.size() < 5 && stack.length > 0) + { + hand.takeDomino(stack.pop()); + } } } diff --git a/src/HttpServer.hx b/src/HttpServer.hx new file mode 100644 index 0000000..3921707 --- /dev/null +++ b/src/HttpServer.hx @@ -0,0 +1,52 @@ +package ; + +import beluga.module.account.Account; +import beluga.module.wallet.Wallet; +import beluga.module.market.Market; +import beluga.core.Beluga; +import haxe.ds.Option; + +/** + * ... + * @author Masadow + */ +class HttpServer +{ + + public function new() + { + + } + + public function login(id : Int) + { + var acc = Beluga.getInstance().getModuleInstance(Account); + var usr = acc.getUser(id); + return usr != null ? { id: usr.id, name: usr.login } : null; + } + + public function getMarket(id : Int) + { + //Get user + var acc = Beluga.getInstance().getModuleInstance(Account); + var usr = acc.getUser(id); + //Get user funds + var wallet = Beluga.getInstance().getModuleInstance(Wallet); + var currency = wallet.getSiteCurrencyOrDefault(); + var fund = wallet.getCurrentFunds(usr, currency); + var credit : Float; + switch (fund) + { + case None: + credit = 0; + case Some(v): + credit = v; + } + //Get products + var market = Beluga.getInstance().getModuleInstance(Market); + var products = market.getProductList(); + //Return all informations + return {fund: credit, currency: currency.cu_name, products: products}; + } + +} \ No newline at end of file diff --git a/src/Main.hx b/src/Main.hx index 79e7005..7d58ac8 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -4,6 +4,7 @@ import beluga.core.Beluga; import beluga.core.api.BelugaApi; import beluga.core.Widget; import beluga.core.BelugaException; +import haxe.remoting.HttpConnection; import haxe.web.Dispatch; import haxe.Resource; import haxe.crypto.Md5; @@ -27,6 +28,9 @@ import neko.Web; class Main { public static var beluga : Beluga; + + //public static var socket; + //public static var cnx; static function main() @@ -37,18 +41,20 @@ class Main { if (Web.getClientHeader("X_HAXE_REMOTING") == "1") { var ctx = new haxe.remoting.Context(); - ctx.addObject("Server",new Server()); - if( haxe.remoting.HttpConnection.handleRequest(ctx) ) - return; + ctx.addObject("Server", new HttpServer()); + if (HttpConnection.handleRequest(ctx)) + return ; } else { Assets.build(); Dispatch.run(beluga.getDispatchUri(), Web.getParams(), new Main()); } - } catch (e : BelugaException) { - trace(e); + } catch (e : Dynamic) { + Dispatch.run("/", Web.getParams(), new Main()); +// trace(e); } +// socket.close(); beluga.cleanup(); } diff --git a/src/game/Game.hx b/src/game/Game.hx index 2ff2793..8003a34 100644 --- a/src/game/Game.hx +++ b/src/game/Game.hx @@ -32,4 +32,4 @@ class Game implements MetadataReader { var html = Renderer.renderDefault("game_page", "Dominax", {host : Web.getClientHeader("Host"), user: user}); Sys.print(html); } -} \ No newline at end of file +} diff --git a/src/services/account/AccountService.hx b/src/services/account/AccountService.hx index d7532e0..afd18ae 100644 --- a/src/services/account/AccountService.hx +++ b/src/services/account/AccountService.hx @@ -21,16 +21,19 @@ class AccountService implements MetadataReader { public function new(beluga : Beluga) { this.beluga = beluga; this.acc = beluga.getModuleInstance(Account); + + //Setting triggers + acc.triggers.loginSuccess.add(this.loginSuccess); + acc.triggers.loginFail.add(this.loginFail); + acc.triggers.afterLogout.add(this.logout); + acc.triggers.subscribeSuccess.add(this.subscribeSuccess); + acc.triggers.subscribeFail.add(this.subscribeFail); + acc.triggers.showUser.add(this.printCustomUserInfo); } /* - * Logination + * Login */ - @bTrigger("beluga_account_login_success") - public static function _loginSuccess(u:User) { - new AccountService(Beluga.getInstance()).loginSuccess(); - } - public function loginSuccess() { var html = Renderer.renderDefault("page_accueil", "Home", { success : "Authentification succeeded !", @@ -39,12 +42,7 @@ class AccountService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_account_login_fail") - public static function _loginFail() { - new AccountService(Beluga.getInstance()).loginFail(); - } - - public function loginFail() { + public function loginFail(_ : {err : String}) { var widget = acc.getWidget("login"); widget.context = {error : "Invalid login and/or password"}; var loginWidget = widget.render(); @@ -54,11 +52,6 @@ class AccountService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_account_logout") - public static function _logout() { - new AccountService(Beluga.getInstance()).logout(); - } - public function logout() { var html = Renderer.renderDefault("page_accueil", "Home", { success : "You're disconnected !", @@ -67,44 +60,26 @@ class AccountService implements MetadataReader { Sys.print(html); } - /* - * Subscription - */ - @bTrigger("beluga_account_subscribe_success") - public static function _subscribeSuccess(user : User) { - new AccountService(Beluga.getInstance()).subscribeSuccess(user); - } - - public function subscribeSuccess(user : User) { + public function subscribeSuccess(user : {user : User}) { var html = Renderer.renderDefault("page_accueil", "Home", { success : "Subscribe succeeded !", - login: user.login + login: user.user.login }); //Autologin - Beluga.getInstance().getModuleInstance(Account).setLoggedUser(user); + Beluga.getInstance().getModuleInstance(Account).loggedUser = user.user; Sys.print(html); } - @bTrigger("beluga_account_subscribe_fail") - public static function _subscribeFail(error : String) { - new AccountService(Beluga.getInstance()).subscribeFail(error); - } - - public function subscribeFail(error : String) { + public function subscribeFail(error : {err : String}) { var subscribeWidget = acc.getWidget("subscribe"); - subscribeWidget.context = {error : error}; + subscribeWidget.context = {error : error.err}; var html = Renderer.renderDefault("page_subscribe", "Inscription", { - subscribeWidget: subscribeWidget.render(), error : error + subscribeWidget: subscribeWidget.render(), error : error.err }); Sys.print(html); } - @bTrigger("beluga_account_show_user") - public function _printCustomUserInfo(args: { id: Int }) { - new AccountService(Beluga.getInstance()).printCustomUserInfo(args); - } - public function printCustomUserInfo(args: { id: Int }) { var user = Beluga.getInstance().getModuleInstance(Account).getLoggedUser(); diff --git a/src/services/account/AccountServiceApi.hx b/src/services/account/AccountServiceApi.hx index d0565ba..abfa940 100644 --- a/src/services/account/AccountServiceApi.hx +++ b/src/services/account/AccountServiceApi.hx @@ -63,7 +63,7 @@ class AccountServiceApi { } public function doDefault(d : Dispatch) { - var login = if (Beluga.getInstance().getModuleInstance(Account).isLogged()) { + var login = if (Beluga.getInstance().getModuleInstance(Account).isLogged) { Beluga.getInstance().getModuleInstance(Account).getLoggedUser().login; } else { "unknown user"; @@ -102,7 +102,7 @@ class AccountServiceApi { } public function doSave(args : {email : String}) { - this.acc.edit(args.email); + this.acc.edit(Beluga.getInstance().getModuleInstance(Account).getLoggedUser().id, args.email); } public static function _doEditSuccess() { diff --git a/src/services/market/MarketService.hx b/src/services/market/MarketService.hx index cfb7757..bae65a0 100644 --- a/src/services/market/MarketService.hx +++ b/src/services/market/MarketService.hx @@ -28,12 +28,13 @@ class MarketService implements MetadataReader { public function new(beluga : Beluga) { this.beluga = beluga; this.market = beluga.getModuleInstance(Market); - } - - @bTrigger("beluga_market_add_product_to_cart_success", - "beluga_market_add_product_to_cart_fail") - public static function _doMarketPage() { - new MarketService(Beluga.getInstance()).doMarketPage(); + + market.triggers.addProductSuccess.add(this.doMarketPage); + market.triggers.addProductFail.add(this.doMarketPage); + market.triggers.removeProductFail.add(this.doCartPage); + market.triggers.removeProductSuccess.add(this.doCartPage); + market.triggers.checkoutCartFail.add(this.doCartPage); + market.triggers.checkoutCartSuccess.add(this.doCartPage); } public function doMarketPage() { @@ -41,18 +42,12 @@ class MarketService implements MetadataReader { marketWidget.context = this.market.getDisplayContext(); var html = Renderer.renderDefault("page_market_widget", "The market", { - marketWidget: marketWidget.render(), + marketWidget: market.widgets.display.render() }); + trace(market.widgets.display.render()); Sys.print(html); } - @bTrigger("beluga_market_remove_product_in_cart_fail", - "beluga_market_remove_product_in_cart_success", - "beluga_market_checkout_cart_fail") - public static function _doCartPage() { - new MarketService(Beluga.getInstance()).doCartPage(); - } - public function doCartPage() { var marketCartWidget = this.market.getWidget("cart"); marketCartWidget.context = this.market.getCartContext(); @@ -73,10 +68,5 @@ class MarketService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_market_checkout_cart_success") - public static function _doCheckoutSuccess() { - new MarketService(Beluga.getInstance()).doCartPage(); - } - - public function doDefault(d : Dispatch) { MarketService._doMarketPage(); } + public function doDefault(d : Dispatch) { doMarketPage(); } } \ No newline at end of file diff --git a/src/services/news/NewsService.hx b/src/services/news/NewsService.hx index e578a62..b278208 100644 --- a/src/services/news/NewsService.hx +++ b/src/services/news/NewsService.hx @@ -62,11 +62,24 @@ class NewsService implements MetadataReader { this.news = beluga.getModuleInstance(News); this.error_msg = ""; this.success_msg = ""; - } - - @bTrigger("beluga_news_default") - public static function _doDefault() { - new NewsService(Beluga.getInstance()).doDefault(); + + //Attach triggers + news.triggers.defaultNews.add(this.doDefault); + news.triggers.print.add(this.doPrint); + news.triggers.redirect.add(this.doRedirect); + news.triggers.redirectEdit.add(this.doRedirectEdit); + news.triggers.createFail.add(this.doCreateFail); + news.triggers.createSuccess.add(this.doCreateSuccess); + news.triggers.deleteFail.add(this.doDeleteFail); + news.triggers.deleteSuccess.add(this.doDeleteSuccess); + news.triggers.deleteCommentFail.add(this.doDeleteCommentFail); + news.triggers.deleteCommentSuccess.add(this.doDeleteCommentSuccess); + news.triggers.editFail.add(this.doEditFail); + news.triggers.editSuccess.add(this.doEditSuccess); + news.triggers.addCommentFail.add(this.doAddCommentFail); + news.triggers.addCommentSuccess.add(this.doAddCommentSuccess); + news.triggers.deleteFail.add(this.doDeleteFail); + news.triggers.deleteSuccess.add(this.doDeleteSuccess); } public function doDefault() { @@ -94,11 +107,6 @@ class NewsService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_news_print") - public static function _doPrint(args : {news_id : Int}) { - new NewsService(Beluga.getInstance()).doPrint(args); - } - public function doPrint(args : {news_id : Int}) { var user = Beluga.getInstance().getModuleInstance(Account).getLoggedUser(); var news = NewsModel.manager.get(args.news_id); @@ -126,11 +134,6 @@ class NewsService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_news_redirect") - public static function _doRedirect() { - new NewsService(Beluga.getInstance()).doRedirect(); - } - public function doRedirect() { if (Beluga.getInstance().getModuleInstance(Account).getLoggedUser() == null) { error_msg = "Please log in !"; @@ -148,11 +151,6 @@ class NewsService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_news_redirectEdit") - public static function _doRedirectEdit(args : {news_id : Int}) { - new NewsService(Beluga.getInstance()).doRedirectEdit(args); - } - public function doRedirectEdit(args : {news_id : Int}) { var user = Beluga.getInstance().getModuleInstance(Account).getLoggedUser(); if (user == null) { @@ -177,58 +175,16 @@ class NewsService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_news_create") - public static function _doCreate(args : {title : String, text : String}) { - new NewsService(Beluga.getInstance()).doCreate(args); - } - - public function doCreate(args : {title : String, text : String}) { - this.news.create(args); - } - - @bTrigger("beluga_news_delete") - public static function _doDelete(args : {news_id : Int}) { - new NewsService(Beluga.getInstance()).doDelete(args); - } - - public function doDelete(args : {news_id : Int}) { - this.news.delete(args); - } - - @bTrigger("beluga_news_deleteCom") - public static function _doDeleteCom(args : {com_id : Int, news_id : Int}) { - new NewsService(Beluga.getInstance()).doDeleteCom(args); - } - - public function doDeleteCom(args : {com_id : Int, news_id : Int}) { - this.news.deleteComment({news_id : args.news_id, comment_id : args.com_id}); - } - - @bTrigger("beluga_news_deleteComment_fail") - public static function _doDeleteCommentFail(args : {news_id : Int, error : String}) { - new NewsService(Beluga.getInstance()).doDeleteCommentFail(args); - } - public function doDeleteCommentFail(args : {news_id : Int, error : String}) { error_msg = args.error; this.doPrint({news_id : args.news_id}); } - @bTrigger("beluga_news_deleteComment_success") - public static function _doDeleteCommentSuccess(args : {news_id : Int}) { - new NewsService(Beluga.getInstance()).doDeleteCommentSuccess(args); - } - public function doDeleteCommentSuccess(args : {news_id : Int}) { success_msg = "Comment has been deleted successfully"; this.doPrint({news_id : args.news_id}); } - @bTrigger("beluga_news_create_fail") - public static function _doCreateFail(args : {title : String, data : String, error : String}) { - new NewsService(Beluga.getInstance()).doCreateFail(args); - } - public function doCreateFail(args : {title : String, data : String, error : String}) { error_msg = "Error ! News has not been created..."; var widget = news.getWidget("create"); @@ -242,92 +198,39 @@ class NewsService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_news_create_success") - public static function _doCreateSuccess() { - new NewsService(Beluga.getInstance()).doCreateSuccess(); - } - public function doCreateSuccess() { success_msg = "News has been successfully created !"; this.doDefault(); } - @bTrigger("beluga_news_edit_fail") - public static function _doEditFail(args : {news_id : Int, error : String}) { - new NewsService(Beluga.getInstance()).doEditFail(args); - } - public function doEditFail(args : {news_id : Int, error : String}) { error_msg = args.error; this.doRedirectEdit({news_id : args.news_id}); } - @bTrigger("beluga_news_edit_success") - public static function _doEditSuccess(args : {news_id : Int}) { - new NewsService(Beluga.getInstance()).doEditSuccess(args); - } - public function doEditSuccess(args : {news_id : Int}) { success_msg = "News has been successfully edited !"; this.doPrint(args); } - @bTrigger("beluga_news_addComment_success") - public static function _doAddCommentSuccess(args : {news_id : Int}) { - new NewsService(Beluga.getInstance()).doAddCommentSuccess(args); - } - public function doAddCommentSuccess(args : {news_id : Int}) { success_msg = "Comment has been successfully added !"; this.doPrint(args); } - @bTrigger("beluga_news_addComment_fail") - public static function _doAddCommentFail(args : {news_id : Int}) { - new NewsService(Beluga.getInstance()).doAddCommentSuccess(args); - } - public function doAddCommentFail(args : {news_id : Int}) { error_msg = "Error ! Comment hasn't been added..."; this.doPrint(args); } - @bTrigger("beluga_news_delete_success") - public static function _doDeleteSuccess() { - new NewsService(Beluga.getInstance()).doDeleteSuccess(); - } - public function doDeleteSuccess() { success_msg = "News has been successfully deleted !"; this.doDefault(); } - @bTrigger("beluga_news_delete_fail") - public static function _doDeleteFail() { - new NewsService(Beluga.getInstance()).doDeleteFail(); - } - public function doDeleteFail() { error_msg = "Error: News hasn't been deleted..."; this.doDefault(); } - @bTrigger("beluga_news_createComment") - public static function _doCreateComment(args : {news_id : Int, text : String}) { - new NewsService(Beluga.getInstance()).doCreateComment(args); - } - - public function doCreateComment(args : {news_id : Int, text : String}) { - this.news.addComment(args); - this.doPrint({news_id: args.news_id}); - } - - @bTrigger("beluga_news_edit") - public static function _doEdit(args : {news_id : Int, title : String, text : String}) { - new NewsService(Beluga.getInstance()).doEdit(args); - } - - public function doEdit(args : {news_id : Int, title : String, text : String}) { - this.news.edit(args); - } } \ No newline at end of file diff --git a/src/services/notification/NotificationService.hx b/src/services/notification/NotificationService.hx index 4c30e4e..efcea23 100644 --- a/src/services/notification/NotificationService.hx +++ b/src/services/notification/NotificationService.hx @@ -31,11 +31,13 @@ class NotificationService implements MetadataReader { this.notif = beluga.getModuleInstance(Notification); this.error_msg = ""; this.success_msg = ""; - } - - @bTrigger("beluga_notif_default") - public static function _doDefault() { - new NotificationService(Beluga.getInstance()).doDefault(); + + this.notif.triggers.createFail.add(doCreateFail); + this.notif.triggers.createSuccess.add(doCreateSuccess); + this.notif.triggers.defaultNotification.add(doDefault); + this.notif.triggers.deleteFail.add(doDeleteFail); + this.notif.triggers.deleteSuccess.add(doDeleteSuccess); + this.notif.triggers.print.add(doPrint); } public function doDefault() { @@ -56,11 +58,6 @@ class NotificationService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_notif_printx") - public static function _doPrint(args : {notif : NotificationModel}) { - new NotificationService(Beluga.getInstance()).doPrint(args); - } - public function doPrint(args : {notif : NotificationModel}) { var user = Beluga.getInstance().getModuleInstance(Account).getLoggedUser(); if (user == null) { @@ -83,38 +80,18 @@ class NotificationService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_notif_create_fail") - public static function _doCreateFail() { - new NotificationService(Beluga.getInstance()).doCreateFail(); - } - public function doCreateFail() { error_msg = "Error ! Notification has not been created..."; this.doDefault(); } - @bTrigger("beluga_notif_create_success") - public static function _doCreateSuccess() { - new NotificationService(Beluga.getInstance()).doCreateSuccess(); - } - public function doCreateSuccess() {} - @bTrigger("beluga_notif_delete_success") - public static function _doDeleteSuccess() { - new NotificationService(Beluga.getInstance()).doDeleteSuccess(); - } - public function doDeleteSuccess() { success_msg = "Notification has been successfully deleted !"; this.doDefault(); } - @bTrigger("beluga_notif_delete_fail") - public static function _doDeleteFail() { - new NotificationService(Beluga.getInstance()).doDeleteFail(); - } - public function doDeleteFail() { error_msg = "Error when trying to delete notification..."; this.doDefault(); diff --git a/src/services/survey/SurveyService.hx b/src/services/survey/SurveyService.hx index 110dda2..3d44866 100644 --- a/src/services/survey/SurveyService.hx +++ b/src/services/survey/SurveyService.hx @@ -34,11 +34,18 @@ class SurveyService implements MetadataReader { this.survey = beluga.getModuleInstance(Survey); this.error_msg = ""; this.success_msg = ""; - } - - @bTrigger("beluga_survey_default") - public static function _doDefault() { - new SurveyService(Beluga.getInstance()).doDefault(); + + survey.triggers.redirect.add(doRedirectPage); + survey.triggers.answerNotify.add(this.doAnswerNotify); + survey.triggers.createFail.add(this.doCreateFail); + survey.triggers.createSuccess.add(this.doCreateSuccess); + survey.triggers.defaultSurvey.add(this.doDefault); + survey.triggers.deleteFail.add(this.doDeleteFail); + survey.triggers.deleteSuccess.add(this.doDeleteSuccess); + survey.triggers.printSurvey.add(this.doPrintPage); + survey.triggers.redirect.add(this.doRedirectPage); + survey.triggers.voteFail.add(this.doVoteFail); + survey.triggers.voteSuccess.add(this.doVoteSuccess); } public function doDefault() { @@ -61,11 +68,6 @@ class SurveyService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_survey_redirect") - public static function _doRedirectPage() { - new SurveyService(Beluga.getInstance()).doRedirectPage(); - } - public function doRedirectPage() { if (Beluga.getInstance().getModuleInstance(Account).getLoggedUser() == null) { Web.setHeader("Content-Type", "text/plain"); @@ -83,41 +85,21 @@ class SurveyService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_survey_create_fail") - public static function _doCreateFail() { - new SurveyService(Beluga.getInstance()).doCreateFail(); - } - public function doCreateFail() { error_msg = "Error ! Survey has not been created..."; this.doDefault(); } - @bTrigger("beluga_survey_create_success") - public static function _doCreateSuccess() { - new SurveyService(Beluga.getInstance()).doCreateSuccess(); - } - public function doCreateSuccess() { success_msg = "Survey has been successfully created !"; this.doDefault(); } - @bTrigger("beluga_survey_delete_success") - public static function _doDeleteSuccess() { - new SurveyService(Beluga.getInstance()).doDeleteSuccess(); - } - public function doDeleteSuccess() { success_msg = "Survey has been successfully deleted !"; this.doDefault(); } - @bTrigger("beluga_survey_delete_success") - public static function _doDeleteFail() { - new SurveyService(Beluga.getInstance()).doDeleteFail(); - } - public function doDeleteFail() { error_msg = "Error when trying to delete survey..."; this.doDefault(); @@ -139,28 +121,18 @@ class SurveyService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_survey_vote_success") - public static function _doVoteSuccess() { - new SurveyService(Beluga.getInstance()).doVoteSuccess(); - } - public function doVoteSuccess() { success_msg = "Your vote has been registered"; this.doDefault(); } - @bTrigger("beluga_survey_vote_fail") - public static function _doVoteFail() { - new SurveyService(Beluga.getInstance()).doVoteFail(); - } - - public function doVoteFail() { - error_msg = "Error when registering your vote..."; + public function doVoteFail(args : {err: String}) { + error_msg = args.err; this.doDefault(); } public function doVotePage(args : {survey : SurveyModel}) { - if (Beluga.getInstance().getModuleInstance(Account).isLogged() == false) { + if (Beluga.getInstance().getModuleInstance(Account).isLogged == false) { Web.setHeader("Content-Type", "text/plain"); Sys.println("Please log in !"); return; @@ -186,26 +158,21 @@ class SurveyService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_survey_printx") - public static function _doPrintPage(args : {survey : SurveyModel}) { - new SurveyService(Beluga.getInstance()).doPrintPage(args); - } - - public function doPrintPage(args : {survey : SurveyModel}) { - if (Beluga.getInstance().getModuleInstance(Account).isLogged() == false) { + public function doPrintPage(args : {survey_id : Int}) { + if (Beluga.getInstance().getModuleInstance(Account).isLogged == false) { Web.setHeader("Content-Type", "text/plain"); Sys.println("Please log in !"); return; } - if (this.survey.canVote({id : args.survey.id})) { - doVotePage({survey : args.survey}); + if (this.survey.canVote({survey_id : args.survey_id})) { + doVotePage({survey : this.survey.getSurvey(args.survey_id)}); return; } var arr = new Array(); var choices = new Array(); var tot = 0; - for (tmp_r in Result.manager.dynamicSearch( { survey_id : args.survey.id } )) { + for (tmp_r in Result.manager.dynamicSearch( { survey_id : args.survey_id } )) { tot += 1; var found = false; for (t in arr) { @@ -217,7 +184,7 @@ class SurveyService implements MetadataReader { if (found == false) arr.push({id : tmp_r.choice_id, pourcent : 1}); } - for (tmp_c in Choice.manager.dynamicSearch( { survey_id : args.survey.id } )) { + for (tmp_c in Choice.manager.dynamicSearch( { survey_id : args.survey_id } )) { var done = false; for (tmp in arr) { if (tmp.id == tmp_c.id) { @@ -230,7 +197,7 @@ class SurveyService implements MetadataReader { } } var widget = survey.getWidget("print_survey"); - widget.context = {survey : args.survey, choices : choices, path : "/beluga/survey/"}; + widget.context = {survey : this.survey.getSurvey(args.survey_id), choices : choices, path : "/beluga/survey/"}; var surveyWidget = widget.render(); @@ -240,8 +207,7 @@ class SurveyService implements MetadataReader { Sys.print(html); } - // @bTrigger("beluga_survey_answer_notify") - public function _doAnswerNotify(args : {title : String, text : String, user_id: Int}) { + public function doAnswerNotify(args : {title : String, text : String, user_id: Int}) { var notification = Beluga.getInstance().getModuleInstance(Notification); notification.create(args); } diff --git a/src/services/ticket/TicketService.hx b/src/services/ticket/TicketService.hx index 6014d14..f124006 100644 --- a/src/services/ticket/TicketService.hx +++ b/src/services/ticket/TicketService.hx @@ -28,11 +28,11 @@ class TicketService implements MetadataReader { public function new(beluga : Beluga) { this.beluga = beluga; this.ticket = beluga.getModuleInstance(Ticket); - } - @bTrigger("beluga_ticket_show_browse") - public static function _doBrowsePage() { - new TicketService(Beluga.getInstance()).doBrowsePage(); + this.ticket.triggers.browse.add(doBrowsePage); + this.ticket.triggers.create.add(doCreatePage); + this.ticket.triggers.show.add(doShowPage); + this.ticket.triggers.assignNotify.add(doNotifyAssign); } public function doBrowsePage() { @@ -45,11 +45,6 @@ class TicketService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_ticket_show_create") - public static function _doCreatePage() { - new TicketService(Beluga.getInstance()).doCreatePage(); - } - public function doCreatePage() { var ticketWidget = ticket.getWidget("create"); ticketWidget.context = ticket.getCreateContext(); @@ -60,11 +55,6 @@ class TicketService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_ticket_show_show") - public static function _doShowPage() { - new TicketService(Beluga.getInstance()).doShowPage(); - } - public function doShowPage() { var ticketWidget = ticket.getWidget("show"); ticketWidget.context = ticket.getShowContext(); @@ -76,7 +66,7 @@ class TicketService implements MetadataReader { } public function doDefault(d : Dispatch) { - TicketService._doBrowsePage(); + doBrowsePage(); } public static function _doAdminPage() { @@ -94,8 +84,7 @@ class TicketService implements MetadataReader { Sys.print(html); } - @bTrigger("beluga_ticket_assign_notify") - public function _doNotifyAssign(args : {title : String, text : String, user_id: Int}) { + public function doNotifyAssign(args : {title : String, text : String, user_id: Int}) { var notification = Beluga.getInstance().getModuleInstance(Notification); notification.create(args); } diff --git a/src/services/wallet/WalletService.hx b/src/services/wallet/WalletService.hx index 665143c..a902224 100644 --- a/src/services/wallet/WalletService.hx +++ b/src/services/wallet/WalletService.hx @@ -29,18 +29,15 @@ class WalletService implements MetadataReader { public function new(beluga : Beluga) { this.beluga = beluga; this.wallet = beluga.getModuleInstance(Wallet); - } - - @bTrigger("beluga_wallet_create_success", - "beluga_wallet_create_fail") - public static function _doDemoPage() { - new WalletService(Beluga.getInstance()).doDemoPage(); + + this.wallet.triggers.creationSuccess.add(this.doDemoPage); + this.wallet.triggers.creationFail.add(this.doDemoPage); } public function doDemoPage() { var walletWidget = this.wallet.getWidget("display"); - walletWidget.context = this.wallet.getDisplayContext(); - var has_wallet = if (Beluga.getInstance().getModuleInstance(Account).isLogged()) { + walletWidget.context = this.wallet.getShowContext(); + var has_wallet = if (Beluga.getInstance().getModuleInstance(Account).isLogged) { 1; } else { 0; @@ -55,12 +52,12 @@ class WalletService implements MetadataReader { } public function doBuyCurrency() { - if (Beluga.getInstance().getModuleInstance(Account).isLogged()) { + if (Beluga.getInstance().getModuleInstance(Account).isLogged) { this.wallet.addRealFunds(Beluga.getInstance().getModuleInstance(Account).getLoggedUser(), 10.); } this.doDemoPage(); } - public function doDefault(d : Dispatch) { WalletService._doDemoPage(); } + public function doDefault(d : Dispatch) { doDemoPage(); } } \ No newline at end of file