what is the stack of BGA?

Game development with Board Game Arena Studio
User avatar
thoun
Posts: 1621
Joined: 10 December 2020, 22:25

Re: what is the stack of BGA?

Post by thoun »

I updated my stack to use Typescript & scss (with local build instead of dirty PHP build I previously mentionned).

If you're interested, I explained it on the Readme file on Github project page.

I'll add it to BGA studio wiki documentation later for those interested. I haven't find a way yet to split my code into multiple files, so I want to polish it before sharing.
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: what is the stack of BGA?

Post by Tisaac »

thoun wrote: 06 February 2021, 23:42 I updated my stack to use Typescript & scss (with local build instead of dirty PHP build I previously mentionned).

If you're interested, I explained it on the Readme file on Github project page.

I'll add it to BGA studio wiki documentation later for those interested. I haven't find a way yet to split my code into multiple files, so I want to polish it before sharing.
Splitting scss files is easy, you can do an import in your main file and the scss compiler merge everything into one css file.
For the js part, it would be great if webpack could work hand in hand with dojo builds.
User avatar
Archduke
Posts: 128
Joined: 05 June 2011, 21:58

Re: what is the stack of BGA?

Post by Archduke »

For splitting js files, I put various functions into different files, and then attach them to the main class in the constructor.
It's a bit unusual, but I find it simpler this way, and it means you can arbitrarily split the code how you like.

This does mean having multiple files on the server, but when it comes to deploying live, I can just copy them all into one file (or write a script for it at some point.)

Example:

Code: Select all

define([
	"dojo","dojo/_base/declare",
	"ebg/core/gamegui",

	g_gamethemeurl + "modules/gamename.states.js",
],
function (dojo, declare, gamegui, states) {
	return declare("bgagame.gamename", gamegui, {
		constructor: function(){
				console.log('gamename constructor');
				...
				this.onEnteringState = states.onEnteringState.bind(this);
				this.onLeavingState = states.onLeavingState.bind(this);
				...
		},
	});
});
And gamename.states.js just defines the required functions:

Code: Select all

function onEnteringState( stateName, args ) {
	console.log( 'Entering state: '+stateName );
	
	switch( stateName )
	{
	case 'dummmy':
		break;
	}
}

function onLeavingState( stateName ) {
	console.log( 'Leaving state: '+stateName );
	
	switch( stateName )
	{
	case 'dummmy':
		break;
	}
}

define({ onEnteringState, onLeavingState });
User avatar
thoun
Posts: 1621
Joined: 10 December 2020, 22:25

Re: what is the stack of BGA?

Post by thoun »

That's nice for JS stack.
I updated my conf so now in can split my TS files, and it automatically builds in a single JS file :)
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: what is the stack of BGA?

Post by Tisaac »

Archduke wrote: 07 February 2021, 11:50 For splitting js files, I put various functions into different files, and then attach them to the main class in the constructor.
It's a bit unusual, but I find it simpler this way, and it means you can arbitrarily split the code how you like.

This does mean having multiple files on the server, but when it comes to deploying live, I can just copy them all into one file (or write a script for it at some point.)
That's a bit cumbersome if you want to do something similar to php trait.
I personnaly like to use multi inheritance of dojo class that allow me to use all the function as if it was inside the main class itself, but I didn't manage to make a proper build yet.
User avatar
thoun
Posts: 1621
Joined: 10 December 2020, 22:25

Re: what is the stack of BGA?

Post by thoun »

thoun wrote: 08 February 2021, 09:55 That's nice for JS stack.
I updated my conf so now in can split my TS files, and it automatically builds in a single JS file :)
I created a wiki page to explain how I set up auto-build for my Typescript and SCSS files.
User avatar
shapeshifter999
Posts: 27
Joined: 18 January 2018, 02:23

Re: what is the stack of BGA?

Post by shapeshifter999 »

Wow! Thank you very much everybody! It was a lot of information! It sure that I love typescript support and able to split one large file into multiple files.

Self-diary:

I just discovered that PHP has some typing.
I was able to run tests inside of PhpStorm.

I am currently investigating the page->begin_block and page->insert_block to see if it is possible to create multiple tpl files:
team.tpl
round.tpl
...

and insert them into self::getGameName() . "_" . self::getGameName() .tpl file.

Thank for your support!
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: what is the stack of BGA?

Post by Tisaac »

sderrico wrote: 10 February 2021, 05:45 Wow! Thank you very much everybody! It was a lot of information! It sure that I love typescript support and able to split one large file into multiple files.

Self-diary:

I just discovered that PHP has some typing.
I was able to run tests inside of PhpStorm.

I am currently investigating the page->begin_block and page->insert_block to see if it is possible to create multiple tpl files:
team.tpl
round.tpl
...

and insert them into self::getGameName() . "_" . self::getGameName() .tpl file.

Thank for your support!
Honestly, that's probably useless, just use a bunch of js template instead, you will need some dynamic content anyway.
User avatar
shapeshifter999
Posts: 27
Joined: 18 January 2018, 02:23

Re: what is the stack of BGA?

Post by shapeshifter999 »

Honestly, that's probably useless, just use a bunch of js template instead, you will need some dynamic content anyway.
Thanks for the tip! I will drop this investigation :)
Post Reply

Return to “Developers”