NUS-ALSET / games

Games based on React Game Kit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Props required for tournament customization

walkwel opened this issue · comments

Run Tournament
Custom Code Tournament
Hide Tournament

buttons need to be passed as props to the Tournament component so that they can be controllable and customizable from the parent component.

Example:
RunTournament: True/False
CustomCodeTournament: True/False
HideTournament: True/False

Hi @MKoth
Kindly Check the game folder in achievement repo, I've changed the game codes as per the requirements of the game activity.

Check out these file for the reference:
1 /achievements/src/components/games/passenger-picker/view/App.js
2 /achievements/src/components/games/passenger-picker/view/updater.js

Main changes in these files are that game-data is coming from the props so that props can be pass from a game-activity to a game component.
You need to implement similar changes in the Tournament to meet the requirement of Tournament activity.

Everything will be coming from the props so Keep in mind. A user doesn't have any option to change/select game parameter from Tournament Component. Tournament data come from a tournament activity and result will pass back to the parent component.

Thanks!

These are sample of props sholud be used by game/tournament component to communicate with Achievement Repo

player1Data={
    playMode : 'MANUAL' || 'CUSTOM_CODE',
    code : [ // if not preset, set default
    {
        pyCode : '', // for level 1 
        jsCode : ''
    },
    {
        pyCode : '', // for level 2
        jsCode : ''
    },
    {
        pyCode : '', // for level 3
        jsCode : ''
    }] // codes for multilevels
} 
player2Data={ // this is used in case of student vs student else set default
    playMode : 'MANUAL' || 'CUSTOM_CODE', // default 'CUSTOM_CODE'
    code : [
        {
            pyCode : '',
            jsCode : ''
        },
        {
            pyCode : '',
            jsCode : ''
        },
        {
            pyCode : '',
            jsCode : ''
        }] // 3 levels code
}
gameData={
    scoreToWinGame : 10,
    scoreToWinTournament : 20, // only need is case of tournament
    gameTime : 120, // in seconds
    numberOfUnits : 2, // or botQuantities,
    tournamentSocre: [
        [1.0, 1.0, 1.0], // [ score_of_player1_level1-VS-player2_level1, score_of_player1_level1-VS-player2_level2, score_of_player1_level1-VS-player2_level3 ]
        [0.0, 0.1, 0.0], //  [ score_of_player1_level2-VS-player2_level1 , ..., ...]
        [1.0, 0.0, 0.0] // ...
    ] // this is result of simulation which is saved into firebase Database
}
gameType = "GAME" || "TOURNAMENT" // in case of GAME disable simulation
onSimulationComplete //  pass simulation result / updated tournament score & this will update tournamentSocre in firebase database
onCommit/onComplete/onGameOver //  pass result of game (WIN/LOOSE/EQUAL) & updated code by user & level_Number and run simulation after game complete so that tournament score will update

screenshot from 2018-10-04 05-20-07

Hi @MKoth ,
screenshot

According to what is done and just, got confirmation from @scboesch, that student will submit only one bot controlling code that will compete with 1-3 or more levels, there is no such thing as level1_player1 vs. level1_player2, since level1 will never compete vs. level1 of other player. Currently in tournament table there is no possibility to compete level1 against level1, since it the same level function, that's why there is empty cell at cross point between this functions

image

Yes, I also got that confirmation from @scboesch
Let's keep it like this and let me re-analyze the code and update you.

Hi @walkwel have you got a chance to re-anylize code, otherwise I can implement it the way I suggested?

Hi @MKoth
I've created a PR regarding these changes.
Please review the PR.
Or check on code codesandbox

This code is working for Game activity & but checked for the tournament.