Game API

Sergth

New Member
Joined
Apr 28, 2016
Messages
16
Points
1
I have a little suggestion about how to shorten the time of developing.

Server and client source code access is enabled only to admins and really trustful devs. However, this is only a free time activity, everybody has school/work/social life ... and there is much too many things waiting for creation.

But, how about to release some kind of API?
Of course, you cannot release whole code, BUT, you can release function names with label of what this function does, its parameters and returns.
In the end there will be a document of all serverside and clientside functions and related global variables. Also some quick dataflow diagram should be added.
For describing methods, you can use for example JSDoc standard l http://usejsdoc.org/about-getting-started.htm.
Of course, you don't need to release all functions. Functions related to client-server communication or data encryption is useless for us. We need functions related to game mechanics.

Then, players/programmers, which .. are players - not trusted source, can write isolated objects / methods, where you can just test them, if the code is written in the proper way and for every feature, there is chan of methods, and not one giant method with tons of ifs and so on....

On playerdex, there can be new section with all missing problems (staff must do that, only you know, what original content is not yet implemented). Like: Move - Fire Blast, and every player/programmer can add his solution or discuss and improve solutions of others. After some time, best solution can be used (after staff testing, of course), topic is marked as complete and owner of the solution can get small reward.


With this step, the game can expand very quickly. Also, it can be done relatively easily. Api can be released on wiki, where also keeping things updated is easy. Making a documentation can be time consuming, but not a hard work. Last thing is to create interface for adding source codes. For that, you can use bugtracker mechanics only with WISYWIG editor alowing post preformated text with syntag highlight (I think that some opensource JS editor/addon shold be available.
 

YoYoPokemonMaster

New Member
Joined
Apr 17, 2015
Messages
128
Points
16
Sergth said:
I have a little suggestion about how to shorten the time of developing.

Server and client source code access is enabled only to admins and really trustful devs. However, this is only a free time activity, everybody has school/work/social life ... and there is much too many things waiting for creation.

But, how about to release some kind of API?
Of course, you cannot release whole code, BUT, you can release function names with label of what this function does, its parameters and returns.
In the end there will be a document of all serverside and clientside functions and related global variables. Also some quick dataflow diagram should be added.
For describing methods, you can use for example JSDoc standard l http://usejsdoc.org/about-getting-started.htm.
Of course, you don't need to release all functions. Functions related to client-server communication or data encryption is useless for us. We need functions related to game mechanics.

Then, players/programmers, which .. are players - not trusted source, can write isolated objects / methods, where you can just test them, if the code is written in the proper way and for every feature, there is chan of methods, and not one giant method with tons of ifs and so on....

On playerdex, there can be new section with all missing problems (staff must do that, only you know, what original content is not yet implemented). Like: Move - Fire Blast, and every player/programmer can add his solution or discuss and improve solutions of others. After some time, best solution can be used (after staff testing, of course), topic is marked as complete and owner of the solution can get small reward.


With this step, the game can expand very quickly. Also, it can be done relatively easily. Api can be released on wiki, where also keeping things updated is easy. Making a documentation can be time consuming, but not a hard work. Last thing is to create interface for adding source codes. For that, you can use bugtracker mechanics only with WISYWIG editor alowing post preformated text with syntag highlight (I think that some opensource JS editor/addon shold be available.

Sergth one thing i have to say is the if client source code is released out it can be misused but some hackers are there who decode the client get some info about the server and client most of the staff dont accept this becoz of hackers but this idea is really good and ur really a good suggestor
 

Sergth

New Member
Joined
Apr 28, 2016
Messages
16
Points
1
As I said, I know this is closed source project.

Of course, you cannot release whole code, BUT, you can release function names with label of what this function does, its parameters and returns.

As I said, I want to be released just headers of methods.

ok, small example, but plase, take it really like an example:

Game api described by documentation:

Code:
//This method says, if the pokemon will be burned
//chance pokemon is burnt, 0-1
//returns bool, true for burn.
private bool pokeBurn(double chance)


//General precept of move
//Move is a data class containing moveHits as bool, if the attack hits,
//outputDamage as int, 
//burn,psn,frz,slp,bpsn,par as bools, true for geting effect,
//input parameters are data of pokemons attacker and deffender data class Poke, all inner variables are int values. Variables are:
//hp, att, def, spAtt, spDef, speed,
//abilityID, level, primaryTypeID, secondaryTypeID, heldItemID as int
//returns Move data object for further processing
private Move generalMove(Poke attacker, Poke deffender)

//Move Effectivness formula
//input parameters are integers of ID of types
//returns double 0,25-4 of effectivness
private double moveEffectivness(int attackerTypePrimary, int deffenderTypePrimary, int attackerTypeSecondary, int deffenderTypesecondary)

//Calculate damage formula
//returns damage done by the ability as int
//input parameters:
//attackerLevel as int, attackerAttack as int (attack or spattack value), deffendersDefense as int (def or spdef), baseMoveDamage as int, modifier as int
private int moveDamage (int attackerLevel, int attackerAttack, int deffendersDefense, int baseMoveDamage, int modifier)

Calculate modifier formula
//returns modifier needed for calculate damage formula as a double
//input parameters:
//stab as double - same attack same type for higher ratio 1,5 instead of 1
//effectivness as double
//isCritical as bool
//otherModifier double, value of other factors - held items, abilities
private void moveModifier(double stab, double effectivness, bool isCritical, otherModifier)

//Modifier other formula
//input attackerItemID as int, deffenderItemID as int, attackerabilityID as int, deffenderAbilityID as int
//returns double
private double modifierOther(int attackerItemID,int deffenderItemID, int attackerabilityID, int deffenderAbilityID)

----------------------------------------------------------------------------------------
With this information, any other player can write the actual method, like

Code:
private Move fireBlast(Poke attacker, Poke deffender){
Move fireBlast = new Move();
//default values
fireBlast.moveHits = false;
fireBlast.outputDamage = 0;
fireBlast.burn = false;
fireBlast.psn = false;
fireBlast.frz = false;
fireBlast.slp = false;
fireBlast.bpsn = false;
fireBlast.par = false;

Random rnd = new Random();

int hitchance = rnd.Next(1, 101);
if(hitchance<=15){fireBlast.moveHits = false; return fireBlast;}
else{fireBlast.moveHits = true;}

double stab;
//lets say 3 is for fire
if(attacker.primaryTypeID ==3 || attacker.secondaryType == 3){stab=1.5;} else {stab=1;}

int critchance = rnd.Next(1, 101);
bool critdamage;
if(critchance<=25){critdamage = true;} else {critdamage =false;}

int modifier = moveModifier(stab, moveEffectivness(attacker.primaryTypeID, deffender.primaryTypeID, attacker.secondaryTypeID, deffender.secondaryTypeID), critdamage, modifierOther(attacker.heldItemID, deffender.heldItemID, attacker.abilityID, deffender.abilityID));


//fireblast has 110 base damage
fireBlast.outputDamage= moveDamage (attacker.level, attacker.spAttack, deffender.spDef, 110, modifier);

int burnchance = rnd.Next(1, 101);
bool critdamage;
if(burnchance<=10){fireBlast.burn = true;} else {fireBlast.burn =false;}


return fireBlast;


}


See? No real background code needed .. no constructors, no class details, just names and parameters..., if the core is written in lets say the correct way.
As I said, take this like an example, I know that real problematics would be much complicated and the real hierarchy or structure of code is different, this was like what I was able to write down in couple of minutes here without code editor and real knowledge of the problematic.

Also, if you concern about misuse of code done by players, code snippets can not being shown to others, leaving players see only which section/problem was completed. Every player will be able only to see, extend and edit his own piece of code
 

Nikola

Youngster
Joined
Jan 8, 2012
Messages
1,762
Points
36
Similar method can be used to have Game Editors doing battle mechanics such as moves. They can also create scripting function for themselves. Not many staff, if any, would be comfortable with that API you mentioned above.
 
Top