describe("check correct working extra games code", function () {
it("check extra_game call on not extragame code", function (done) {
var localCase = prime({
gamestate_module: gamestate,
inherits: game_mock.GameTestCase,
_free_spin_stage: false,
_bank_on_start: 86046,
_tid: 0,
_holded_transaction: null,
_free_spin_counter: null,
CID: "794121211",
post_build: function () {
var math_module = new math.NewslotsMath()
math_module.free_spin_on_spin = true;
this.gsm.slot_machine._slot_machine = math_module;
this.amount = this._bank_on_start;
},
run: function(){
this.gsm.spin(this.requestSpin());
},
answer_message: function(answer){
expect(answer.service).toBe("answer");
switch (answer.event){
case "newslots_spinoff":
if (this._free_spin_stage == false){
this.check_spinoff(answer);
}
else {
this.check_freespinoff(answer);
}
break
}
},
check_freespinoff: function(msg){
expect(msg.id).toBe(""+this.ID);
expect(msg.args.CreditsOut).toBe(this.amount);
expect(msg.args.FreeSpinCount).toBe(this._free_spin_counter - 1);
this._free_spin_counter -= 1;
if (this._free_spin_counter == 0) {
return this.done();
}
this.next_free_spin();
},
check_spinoff: function(msg){
expect(msg.id).toBe(""+this.ID);
expect(msg.args.CreditsInter).toBe(this.amount);
expect(msg.args.FreeGamePrizes.length).toBe(5);
expect(msg.args.FreeSpinCount).toBe(5);
expect(msg.args.CurrentWin).toBe(0);
expect(msg.args.TotalWin).toBe(0);
this._free_spin_counter = msg.args.FreeSpinCount;
this._free_spin_stage = true;
this.next_free_spin();
},
next_free_spin: function(){
this.ID += 1;
var msg = new registry.games.FreeSpin({}, {id: ""+this.ID, uid: this.UID, cid: this.CID});
expect(msg.validate()).toBe(true);
this.gsm.free_spin(msg.data);
},
internal_message: function(req){
switch (req.event) {
case "commit":
this.transaction_commit(req);
break;
case "transaction":
this.transaction_hold(req);
break;
}
},
transaction_commit: function(msg){
var tid = null;
expect(msg.service).toBe("bank")
if (this._holded_transaction != null ){
expect(msg.args.tid).toBe(this._holded_transaction);
expect(msg.args.hold).toBe(25);
tid = this._holded_transaction;
} else {
this._tid += 1;
tid = ""+this._tid;
}
this.amount += msg.args.fund - msg.args.hold;
var resp = new registry.account.TransactionAnswer({
amount: this.amount,
tid: tid,
state: consts.transaction.STATE_FINISHED
}, msg);
expect(resp.validate()).toBe(true);
this.gsm.transaction_answer(resp.data);
},
transaction_hold: function(msg){
this._tid += 1;
expect(msg.service).toBe("bank")
expect(msg.args.hold).toBe(25);
var resp = new registry.account.TransactionAnswer({
amount: this.amount,
tid: ""+this._tid,
state: consts.transaction.STATE_STARTED
}, msg);
expect(resp.validate()).toBe(true);
this.gsm.transaction_answer(resp.data);
},
requestSpin: function(){
this.ID += 1;
var msg = new registry.games.Spin({
line: 5, bet: 5, denomination: 1
}, {uid: this.UID, cid: this.CID, id: ""+this.ID});
expect(msg.validate()).toBe(true);
msg = msg.data;
msg.service = "astirbike";
return msg;
}
});
var currentTest = new localCase(done);
currentTest.run();
});
});