瞬駈天魔のツクール素材製作所

月額支援サイトファンティアを追加しました!
是非、無料ファンでも励みになりますので宜しくお願い致します!m(__)m

[データ丸投げ!]スロットプラグイン編集版 (※文字数制限に伴い、後半部)

2018年05月18日 02時50分00秒 | ツクール日記

Scene_SlotMachine.prototype.spinCommand = function () { this._coin -= this._bet * scale; this._slotCommandWindow.deactivate(); this._slotCommandWindow.close(); this._helpWindow.close(); this._winSpot = this.drawLot(); var t = ""; var i; for (i = 0; i < 5; i++) { t += reel[i][this._winSpot[i]]; } this._rollCount++; //Interval Spin //this._currentStartingReel = 0; //this._startingTimer = setInterval(function(){ // this._reels[this._currentStartingReel].spin(); // this._currentStartingReel++; // console.log("this._currentStartingReel", this._currentStartingReel) // if (this._currentStartingReel > 4) { // clearInterval(this._startingTimer); // this._startingTimer = null; // } //}.bind(this), 200); this._spinStart = true; this._reels[0].setWinSpot(this._winSpot[0]); this._reels[1].setWinSpot(this._winSpot[1]); this._reels[2].setWinSpot(this._winSpot[2]); this._reels[3].setWinSpot(this._winSpot[3]); this._reels[4].setWinSpot(this._winSpot[4]); for (i = 0; i < 5; i++) { this._reels[i].spin(); } }; Scene_SlotMachine.prototype.result = function () { this._rollCount = 0; var win, tmp; win = this.judge(this._winSpot); tmp = win; if (this._coin + win > Scene_SlotMachine.COIN_MAX_VALUE) { win = Scene_SlotMachine.COIN_MAX_VALUE - this._coin; } this._winCoin = this._correctCoin = win; var time = 60 * 10; if (this._winCoin < time) { this._winStep = 1; } else { this._winStep = this._winCoin / time >> 0; } if (this._winCoin > 0) { this._winMessage = winMessage; var reg = /Win Coin/gi; this._winMessage = this._winMessage.replace(reg, String(tmp)); this._helpWindow.setText(this._winMessage); this._helpWindow.open(); AudioManager.playMe({"name": "Victory1", "volume": 90, "pitch": 100, "pan": 0}); } else { this._helpWindow.setText(lostMessage + '\n' + replayMessage); this._helpWindow.open(); this._replayCommandWindow.open(); this._replayCommandWindow.activate(); } }; Scene_SlotMachine.prototype.judge = function (spot) { var result1 = []; result1.push(reel[0][(spot[0] + 1) % reel[0].length]); result1.push(reel[1][(spot[1] + 1) % reel[1].length]); result1.push(reel[2][(spot[2] + 1) % reel[2].length]); result1.push(reel[3][(spot[3] + 1) % reel[3].length]); result1.push(reel[4][(spot[4] + 1) % reel[4].length]); var result2 = []; result2.push(reel[0][spot[0]]); result2.push(reel[1][spot[1]]); result2.push(reel[2][spot[2]]); result2.push(reel[3][spot[3]]); result2.push(reel[4][spot[4]]); var result3 = []; result3.push(reel[0][(this._winSpot[0] - 1 + reel[0].length) % reel[0].length]); result3.push(reel[1][(this._winSpot[1] - 1 + reel[1].length) % reel[1].length]); result3.push(reel[2][(this._winSpot[2] - 1 + reel[2].length) % reel[2].length]); result3.push(reel[3][(this._winSpot[3] - 1 + reel[3].length) % reel[3].length]); result3.push(reel[4][(this._winSpot[4] - 1 + reel[4].length) % reel[4].length]); var returnValue = 0; var cursorArray = this._makeCursorArray(); //line1 var i, base; var win = 0; base = result1[0]; if (this._bet > 1) { for (i = 1; i < 5; i++) { if (base !== result1[i]) { break; } } i--; if (i > 1) { win = scale * odds[i - 2][base]; cursorArray[i - 2][base] = true; returnValue += win; } } //line2 win = 0; base = result2[0]; if (this._bet > 0) { for (i = 1; i < 5; i++) { if (base !== result2[i]) { break; } } i--; if (i > 1) { win = scale * odds[i - 2][base]; cursorArray[i - 2][base] = true; returnValue += win; } } //line3 win = 0; base = result3[0]; if (this._bet > 2) { for (i = 1; i < 5; i++) { if (base !== result3[i]) { break; } } i--; if (i > 1) { win = scale * odds[i - 2][base]; cursorArray[i - 2][base] = true; returnValue += win; } } this._instructionWindow.blinkCursor(cursorArray); return returnValue; }; Scene_SlotMachine.prototype.drawLot = function () { var i, j, l; var s; var spot = []; spot.push(Math.random() * reel[0].length >> 0); spot.push(Math.random() * reel[1].length >> 0); spot.push(Math.random() * reel[2].length >> 0); spot.push(Math.random() * reel[3].length >> 0); spot.push(Math.random() * reel[4].length >> 0); //2〜5reel var l1, l2, l3; var r; var target1 = true; var target2 = true; var target3 = true; for (i = 1; i < 5; i++) { for (j = 0; j < reel[i].length; j++) { if (this.isWin(spot, i)) { spot[i] = (spot[i] + 1) % reel[i].length; } else { break; } } l = reel[i - 1].length; l1 = reel[i - 1][(spot[i - 1] + 1 + l) % l]; l2 = reel[i - 1][(spot[i - 1] + 0 + l) % l]; l3 = reel[i - 1][(spot[i - 1] - 1 + l) % l]; l = reel[i].length; r = Math.random(); if (r < this._probability[i - 1][l2] && target2) { s = reel[i].indexOf(l2); if (s >= 0) { spot[i] = (s + 0 + l) % l; target1 = false; target3 = false; } else { console.error("Illegal lottery. r:", i,"l2:", l2); } } r = Math.random(); if (r < this._probability[i - 1][l1] && target1) { s = reel[i].indexOf(l1); if (s >= 0) { spot[i] = (s - 1 + l) % l; target2 = false; target3 = false; } else { console.error("Illegal lottery. r:", i,"l1:", l1); } } r = Math.random(); if (r < this._probability[i - 1][l3] && target3) { s = reel[i].indexOf(l3); if (s >= 0) { spot[i] = (s + 1 + l) % l; target1 = false; target2 = false; } else { console.error("Illegal lottery. r:", i,"l3:", l3); } } } return spot; }; /** * * @param spot * @param r * @return {boolean} */ Scene_SlotMachine.prototype.isWin = function (spot, r) { return !!( reel[r - 1][(spot[r - 1] + 1) % reel[r - 1].length] === reel[r][(spot[r] + 1) % reel[r].length] || reel[r - 1][(spot[r - 1] + 0) % reel[r - 1].length] === reel[r][(spot[r] + 0) % reel[r].length] || reel[r - 1][(spot[r - 1] - 1) % reel[r - 1].length] === reel[r][(spot[r] - 1) % reel[r].length] ); }; Scene_SlotMachine.prototype.correct = function () { this._coin += this._correctCoin; this._correctCoin = 0; if (this._coin >= Scene_SlotMachine.COIN_MAX_VALUE) { this._helpWindow.setText(coinFullMessage + '\n' + replayMessage); } else { this._helpWindow.setText(this._winMessage + '\n' + replayMessage); } this._winMessage = ""; this._replayCommandWindow.open(); this._replayCommandWindow.activate(); }; Scene_SlotMachine.prototype.replayCommand = function () { this._slotCommandWindow.enableBet(); this._slotCommandWindow.disableSpin(); if (this._coin < scale) { this._slotCommandWindow.disableBet(); } this._slotCommandWindow.select(0); this._replayCommandWindow.close(); this._slotCommandWindow.open(); this._slotCommandWindow.activate(); this._helpWindow.setText(helpMessage); this._bet = 0; this.refreshStatus(); }; Scene_SlotMachine.prototype.refreshStatus = function () { this._slotMachineWindow.bet = this._bet * scale; this._slotMachineWindow.coin = this._coin - this._bet * scale; if (this._bet === 0) { this._betLine.clear(); } else { this._betLine.enableLine(this._bet - 1); } }; Scene_SlotMachine.prototype.update = function () { Scene_MenuBase.prototype.update.call(this); var result = 0; if (this._spinStart && !this.isSpinning()) { this._spinStart = false; this.result(); } else if (this.isWinCounting()) { if (this._winCoin <= this._winStep) { this._winCoin = 0; result = this._coin + this._correctCoin; this._slotMachineWindow.coin = result; this.correct(); } else { this._winCoin -= this._winStep; result = this._coin + this._correctCoin - this._winCoin; this._slotMachineWindow.coin = result; } } if (Input.isRepeated('up') && this._slotCommandWindow.active) { if (this._slotCommandWindow.isAllowBet) { SoundManager.playOk(); this.betCommand(); } else { SoundManager.playBuzzer(); } } if (Input.isRepeated('down') && this._slotCommandWindow.active) { if (this._slotCommandWindow.isAllowSpin && !this._spinStart) { SoundManager.playOk(); this.spinCommand(); } } }; Scene_SlotMachine.prototype._makeCursorArray = function () { var returnValue = []; for (var i = 0; i < 3; i++) { returnValue.push([]); for (var j = 0; j < 6; j++) { returnValue[i].push(false); } } return returnValue; }; //----------------------------------------------------------------------------- // Window_SlotInstruction // // This window is instruction card for the slot machines. function Window_SlotInstruction() { this.initialize.apply(this, arguments); } Window_SlotInstruction.prototype = Object.create(Window_Base.prototype); Window_SlotInstruction.prototype.constructor = Window_SlotInstruction; Window_SlotInstruction.prototype.initialize = function (x, y, width, height) { Window_Base.prototype.initialize.call(this, x, y, width, height); this._cursol = [[],[],[]]; var b = ImageManager.loadBitmap("img/slotmachine/", "win_cursor"); var cx = 47; var cy = 32; var cw = 224; for (var i = 2; i >= 0; i--) { for (var j = 5; j >= 0; j--) { var sprite = new InstructionCursorSprite(b); this.addChild(sprite); sprite.x = cx + i * (cw + 20); sprite.y = cy + j * 24; this._cursol[2 - i].push(sprite); } } this.clearCursor(); }; Window_SlotInstruction.prototype.lineHeight = function () { return 24; }; Window_SlotInstruction.prototype.refresh = function () { this.setBackgroundType(2); this.contents.clear(); if (this._odds) { this.contents.fontSize = 22; var x = 51 - 18; var y = 14; var w = 224; this.drawText(this._odds[2][5], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[2][4], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[2][3], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[2][2], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[2][1], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[2][0], x, y, w, "right"); x += w + 20; y = 14; this.drawText(this._odds[1][5], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[1][4], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[1][3], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[1][2], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[1][1], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[1][0], x, y, w, "right"); x += w + 20; y = 14; this.drawText(this._odds[0][5], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[0][4], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[0][3], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[0][2], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[0][1], x, y, w, "right"); y += this.lineHeight(); this.drawText(this._odds[0][0], x, y, w, "right"); } this.contents.fontSize = this.standardFontSize(); }; Window_SlotInstruction.prototype.setOdds = function (odds) { this._odds = odds; }; Window_SlotInstruction.prototype.clearCursor = function () { for (var i = 0; i
 

ここまでになります。
長いですが、まぁ・・・仕方なし・・・(-_-;)
そのままコピペしたら、お食事万歳!!になりますからね!!(`・ω・´)
 

[データ丸投げ!]スロットプラグイン編集版 (※文字数制限に伴い、前半部まで)

2018年05月18日 02時45分00秒 | ツクール日記

はい、こちらはスロットプラグインのデータ丸投げ!!

と言っても、そのまま丸投げすると・・・ネタになります!!(`・ω・´)

ちゃんとコピペする前に一部は修正しないと・・・お食事ネタになりますよ!!(`・ω・´)

何故、JSファイルで出さないのかって・・・?

そのままお食事ネタで使いそうじゃないですか!!(`・ω・´;)

文字数制限の関係上、こっちは前半部で次に記載するのは後半部となります。

まず前半部のこれをコピーしたらメモ帳へペースト(貼り付け)をしたら、
そのメモ帳内の一番下に後半部のプラグインデータをコピーして貼り付けをし、
保存時のファイル名を「SlotMachine.js」で
右側の選択は「すべてのファイル」を選択して保存すると「JSファイル」が出来上がります。

・・・という訳でこちら!! ↓

 

//=============================================================================
// SlotMachine.js
//
// (c)2016 KADOKAWA CORPORATION./YOJI OJIMA
//=============================================================================

/*:
 * @plugindesc Slot Machine scene
 * @author Takeya Kimura
 *
 * @param Variable ID
 * @desc Variable ID for store the coin.
 * @default 11
 *
 * @param Help Text
 * @desc This text is a help message.
 * @default カーソルキーの上でベッド、カーソルキーの下でお食事開始
 *
 * @param Won Text
 * @desc This text is a won message. "Win Coin" will be replaced with the number of coins won.
 * @default おめでとうございます!Win Coin肉獲得です!
 *
 * @param Lost Text
 * @desc This text is a lost message.
 * @default ご馳走様でした。
 *
 * @param Replay Text
 * @desc This text is a replay message.
 * @default もう一度ご馳走になりますか?
 *
 * @param CoinFull Text
 * @desc This text is a coin full message.
 * @default お腹が満腹になりました。
 *
 * @param Bet Text
 * @desc This text is a bet command.
 * @default ベッド
 *
 * @param Spin Text
 * @desc This text is a coin spin command.
 * @default フライスピン
 *
 * @param Yes Text
 * @desc This text is a coin "yes" command.
 * @default お食事開始
 *
 * @param No Text
 * @desc This text is a "no" command.
 * @default もう食べれません
 *
 * @requiredAssets img/slotmachine/bet_line_1
 * @requiredAssets img/slotmachine/bet_line_2
 * @requiredAssets img/slotmachine/bet_line_3
 * @requiredAssets img/slotmachine/bg
 * @requiredAssets img/slotmachine/line_base
 * @requiredAssets img/slotmachine/reel
 * @requiredAssets img/slotmachine/scale_x1
 * @requiredAssets img/slotmachine/scale_x10
 * @requiredAssets img/slotmachine/scale_x100
 * @requiredAssets img/slotmachine/win_cursor
 * @requiredAssets audio/me/Victory1
 * @requiredAssets audio/se/Switch2
 *
 * @help
 * Plugin Command:
 *   SlotMachine open               # Open the slot machines
 *   SlotMachine expectation 0.5    # Set the expectation
 *   SlotMachine scale 0            # Set the scale [0 | 1 | 2](scale1 | scale10 | scale100)
 */

/*:ja
 * @plugindesc Slot Machine scene
 * @author Takeya Kimura
 *
 * @param Variable ID
 * @desc 所持お肉の数を保管する変数ID
 * @default 11
 *
 * @param Help Text
 * @desc ヘルプメッセージです。
 * @default カーソルキーの上でベッド、カーソルキーの下でお食事 *
 * @param Won Text
 * @desc 食事後のメッセージ。 "Win Coin"は獲得したお肉に置換されます。
 * @default おめでとうございます!Win Coin肉獲得です!
 *
 * @param Lost Text
 * @desc 食べれなかった時のメッセージ
 * @default 食べれませんでした。
 *
 * @param Replay Text
 * @desc 温め時の選択メッセージ
 * @default もう一度ご馳走になりますか?
 *
 * @param Coin Full Text
 * @desc お肉で満腹に達した時のメッセージ
 * @default お腹が満腹になりました。
 *
 * @param Bet Text
 * @desc ベットコマンドのテキスト
 * @default ベッド
 *
 * @param Spin Text
 * @desc スピンコマンドのテキスト
 * @default フライスピン
 *
 * @param Yes Text
 * @desc はいコマンドのテキスト
 * @default お食事開始
 *
 * @param No Text
 * @desc いいえコマンドのテキスト
 * @default もう食べれません
 *
 * @requiredAssets img/slotmachine/bet_line_1
 * @requiredAssets img/slotmachine/bet_line_2
 * @requiredAssets img/slotmachine/bet_line_3
 * @requiredAssets img/slotmachine/bg
 * @requiredAssets img/slotmachine/line_base
 * @requiredAssets img/slotmachine/reel
 * @requiredAssets img/slotmachine/scale_x1
 * @requiredAssets img/slotmachine/scale_x10
 * @requiredAssets img/slotmachine/scale_x100
 * @requiredAssets img/slotmachine/win_cursor
 * @requiredAssets audio/me/Victory1
 * @requiredAssets audio/se/Switch2
 *
 * @help
 * Plugin Command:
 *   SlotMachine open               # 精肉マシーンを開きます
 *   SlotMachine expectation 0.5    # 期待値を0~1の間で設定します。1に近づくほど当たりやすくなりますが、確実にお食事できるわけではありません。
 *   SlotMachine scale 0            # 倍率を設定します0は1倍、1は10倍、2は100倍です。
 */

(function () {

var parameters = PluginManager.parameters('SlotMachine');
var variableId = Number(parameters['Variable ID'] || 11);
var helpMessage = String(parameters['Help Text'] || "カーソルキーの上でベッド、カーソルキーの下でお食事");
var winMessage = String(parameters['Won Text'] || "おめでとうございます!Win Coin肉獲得です!");
var lostMessage = String(parameters['Lost Text'] || "食べれませんでした。");
var replayMessage = String(parameters['Replay Text'] || "もう一度ご馳走になりますか?");
var coinFullMessage = String(parameters['CoinFull Text'] || "お腹が満腹になりました。");
var betText = String(parameters['Bet Text'] || "ベッド");
var spinText = String(parameters['Spin Text'] || "フライスピン");
var yesText = String(parameters['Yes Text'] || "お食事開始");
var noText = String(parameters['No Text'] || "もう食べれません");
var scale = 1;
var expectation = 0.5;

//odds
//You can set the odds.
var odds = [];
odds.push([]);
odds[0].push(3); //000
odds[0].push(5); //111
odds[0].push(10); //222
odds[0].push(30); //333
odds[0].push(500); //444
odds[0].push(777); //555
odds.push([]);
odds[1].push(6); //0000
odds[1].push(30); //1111
odds[1].push(50); //2222
odds[1].push(300); //3333
odds[1].push(5000); //4444
odds[1].push(7777); //5555
odds.push([]);
odds[2].push(20); //00000
odds[2].push(300); //11111
odds[2].push(500); //22222
odds[2].push(3000); //33333
odds[2].push(5000); //44444
odds[2].push(77777); //55555

//make reel
//You can rearrange the order of the reel.
//The number can not be changed.
var reel = [];
reel.push([0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]);
reel.push([5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0]);
reel.push([0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 0, 1, 2, 3, 4, 5]);
reel.push([0, 2, 4, 1, 3, 5, 0, 2, 4, 1, 3, 5, 0, 2, 4, 1, 3, 5]);
reel.push([0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]);

function getCoin() {
    return $gameVariables.value(variableId);
}

function setCoin(value) {
    return $gameVariables.setValue(variableId, value);
}

var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
    _Game_Interpreter_pluginCommand.call(this, command, args);
    if (command === "SlotMachine") {
        switch (args[0]) {
            case "open":
                SceneManager.push(Scene_SlotMachine);
                break;
            case "expectation":
                expectation = Number(args[1]);
                break;
            case "scale":
                switch (args[1]) {
                    case "0":
                        scale = 1;
                        break;
                    case "1":
                        scale = 10;
                        break;
                    case "2":
                        scale = 100;
                        break;
                    default :
                        scale = 1;
                        break;
                }
                break;
        }
    }
};

//-----------------------------------------------------------------------------
// SLTReelSprite
//
// Slot Machine Reel Sprite

function SLTReelSprite() {
    this.initialize.apply(this, arguments);
}

SLTReelSprite.prototype = Object.create(Sprite.prototype);
SLTReelSprite.prototype.constructor = SLTReelSprite;

SLTReelSprite.STOP = 0;
SLTReelSprite.SPINNING = 1;
SLTReelSprite.SPIN = 2;
SLTReelSprite.STOPPING = 3;
SLTReelSprite.FRAME_SPINNING = 40;
SLTReelSprite.FRAME_SPIN = 60;
SLTReelSprite.FRAME_STOPPING = 40;

SLTReelSprite.prototype.initialize = function (bitmap) {
    Sprite.prototype.initialize.call(this, bitmap);
    this._numSpot = 18;
    this._spotHeight = 54;
    this._winSpot = 0;
    this._scrollY = 0;
    this._speedHigh = 30;
    this._speedLow = 4;
    this._status = 0;
    this._spinFrame = 0;
    this._spinEndFrame = SLTReelSprite.FRAME_SPIN;
};

Object.defineProperty(SLTReelSprite.prototype, 'status', {
    get: function () {
        return this._status;
    },
    configurable: true
});

SLTReelSprite.prototype.update = function () {
    Sprite.prototype.update.call(this);

    switch (this._status) {

        case SLTReelSprite.STOP:
            break;

        case SLTReelSprite.SPINNING:
            if (this._spinFrame > SLTReelSprite.FRAME_SPINNING) {
                this._status = SLTReelSprite.SPIN;
                break;
            }
            this._scrollY = (this._scrollY + this._speedLow) % (this._numSpot * this._spotHeight);
            this.setFrame(
                0,
                this._spotHeight * this._numSpot * 2 - this._scrollY - this._spotHeight * 2,
                116,
                this._spotHeight * 3
            );
            this._spinFrame++;
            break;

        case SLTReelSprite.SPIN:
            if (this._spinFrame > this._spinEndFrame + SLTReelSprite.FRAME_SPINNING) {
                this._status = SLTReelSprite.STOPPING;
                this._scrollY = this._winSpot * this._spotHeight - this._spotHeight * 3;
                break;
            }
            this._scrollY = (this._scrollY + this._speedHigh) % (this._numSpot * this._spotHeight);
            this.setFrame(
                0,
                this._spotHeight * this._numSpot * 2 - this._scrollY - this._spotHeight * 2,
                116,
                this._spotHeight * 3
            );
            this._spinFrame++;
            break;

        case SLTReelSprite.STOPPING:
            this._scrollY = (this._scrollY + this._speedLow) % (this._numSpot * this._spotHeight);
            if (this._scrollY > this._winSpot * this._spotHeight) {
                this._scrollY = this._winSpot * this._spotHeight;
                this._status = SLTReelSprite.STOP;
                AudioManager.playSe({"name": "Switch2", "volume": 90, "pitch": 100, "pan": 0});
            }
            this.setFrame(
                0,
                this._spotHeight * this._numSpot * 2 - this._scrollY - this._spotHeight * 2,
                116,
                this._spotHeight * 3
            );
            break;
    }
};

SLTReelSprite.prototype.setSpot = function (spot) {
    if (0  0) {
        if (this._counter > InstructionCursorSprite.FRAME_BLINK_END + 1) {
            this._counter = 0;
        }
        else {
            var s = this._counter / InstructionCursorSprite.FRAME_BLINK >> 0;
            this.visible = s % 2 === 0;
            this._counter++;
        }
    }
};

/**
 * @method drawImage
 * @param bitmap    source bitmap
 * @param sx        source x
 * @param sy        source y
 * @param sw        source width
 * @param sh        source height
 * @param dx        destination x
 * @param dy        destination y
 */
Bitmap.prototype.drawImage = function(bitmap, sx, sy, sw, sh, dx, dy) {
    this._context.drawImage(bitmap.canvas, sx, sy, sw, sh, dx, dy, sw, sh);
    this._setDirty();
};

//-----------------------------------------------------------------------------
// Scene_SlotMachine
//
// Will play the slot machine.

function Scene_SlotMachine() {
    this.initialize.apply(this, arguments);
}

Scene_SlotMachine.prototype = Object.create(Scene_MenuBase.prototype);
Scene_SlotMachine.prototype.constructor = Scene_SlotMachine;

Scene_SlotMachine.COIN_MAX_VALUE = 99999999;
Scene_SlotMachine.ODDS_MAX_VALUE = 100000;

Scene_SlotMachine.prototype.initialize = function () {
    Scene_MenuBase.prototype.initialize.call(this);

    this._bet = 0;
    this._coin = getCoin();
    this._winSpot = null;
    this._spinStart = false;
    this._rollCount = 0;
    this._winCoin = 0;
    this._correctCoin = 0;
    this._winStep = 0;
    this._winMessage = "";

    //Winning percentage is calculated by the odds
    this._probability = [];
    this._probability.push([]);
    this._probability[0].push(0.92); //00
    this._probability[0].push(0.86); //11
    this._probability[0].push(0.69); //22
    this._probability[0].push(0.62); //33
    this._probability[0].push(0.54); //44
    this._probability[0].push(0.46); //55

    this._probability.push([]);
    this._probability[1].push((1 / this._probability[0][0]) *
        expectation * (1 / odds[0][0])); //000
    this._probability[1].push((1 / this._probability[0][1]) *
        expectation * (1 / odds[0][1])); //111
    this._probability[1].push((1 / this._probability[0][2]) *
        expectation * (1 / odds[0][2])); //222
    this._probability[1].push((1 / this._probability[0][3]) *
        expectation * (1 / odds[0][3])); //333
    this._probability[1].push((1 / this._probability[0][4]) *
        expectation * (1 / odds[0][4])); //444
    this._probability[1].push((1 / this._probability[0][5]) *
        expectation * (1 / odds[0][5])); //555

    this._probability.push([]);
    this._probability[2].push((1 / (this._probability[0][0] * this._probability[1][0])) *
        expectation * (1 / odds[1][0])); //0000
    this._probability[2].push((1 / (this._probability[0][1] * this._probability[1][1])) *
        expectation * (1 / odds[1][1])); //1111
    this._probability[2].push((1 / (this._probability[0][2] * this._probability[1][2])) *
        expectation * (1 / odds[1][2])); //2222
    this._probability[2].push((1 / (this._probability[0][3] * this._probability[1][3])) *
        expectation * (1 / odds[1][3])); //3333
    this._probability[2].push((1 / (this._probability[0][4] * this._probability[1][4])) *
        expectation * (1 / odds[1][4])); //4444
    this._probability[2].push((1 / (this._probability[0][5] * this._probability[1][5])) *
        expectation * (1 / odds[1][5])); //5555

    this._probability.push([]);
    this._probability[3].push((1 / (this._probability[0][0] * this._probability[1][0] * this._probability[2][0])) *
        expectation * (1 / odds[2][0])); //00000
    this._probability[3].push((1 / (this._probability[0][1] * this._probability[1][1] * this._probability[2][1])) *
        expectation * (1 / odds[2][1])); //11111
    this._probability[3].push((1 / (this._probability[0][2] * this._probability[1][2] * this._probability[2][2])) *
        expectation * (1 / odds[2][2])); //22222
    this._probability[3].push((1 / (this._probability[0][3] * this._probability[1][3] * this._probability[2][3])) *
        expectation * (1 / odds[2][3])); //33333
    this._probability[3].push((1 / (this._probability[0][4] * this._probability[1][4] * this._probability[2][4])) *
        expectation * (1 / odds[2][4])); //44444
    this._probability[3].push((1 / (this._probability[0][5] * this._probability[1][5] * this._probability[2][5])) *
        expectation * (1 / odds[2][5])); //55555

    //Interval Spin
    //this._startingTimer = null;
    //this._currentStartingReel = 0;

    if (this._coin > Scene_SlotMachine.COIN_MAX_VALUE) {
        this._coin = Scene_SlotMachine.COIN_MAX_VALUE;
    }
};

Scene_SlotMachine.prototype.create = function () {
    this.createBackground();
    this._backgroundSprite.bitmap = ImageManager.loadBitmap("img/slotmachine/", "bg");
    this.createReels();
    this.createBetLine();
    this.createScale();
    this.updateActor();
    this.createWindowLayer();
    this.createHelpWindow();
    this.createInstruction();
    this.createSlotMachine();
    this.createSlotCommand();
    this.createReplayCommand();

    this.refreshStatus();

    if (this._coin < scale) {
        this._slotCommandWindow.disableBet();
    }
};

Scene_SlotMachine.prototype.start = function() {
    this.makeReel();
    this._instructionWindow.refresh();
    this._slotMachineWindow.refresh();
    this._helpWindow.setText(helpMessage);
};

Scene_SlotMachine.prototype.makeReel = function() {
    for (var i = 0; i < 5; i++) {
        for (var j = 0; j < 18; j++) {
            for (var k = 0; k < 3; k++) {
                this._reels[i].bitmap.drawImage(
                    this._reelBitmap,
                    reel[i][j] * 116,
                    0,
                    116,
                    54,
                    0,
                    (54 * 18 * 3) - j * 54 - k * (18 * 54) - 54);
            }
        }

        this._reels[i].setSpot(Math.random() * 18 >> 0);
    }
};

Scene_SlotMachine.prototype.isSpinning = function() {
    var returnValue = false;
    for (var i = 0; i < 5; i++) {
        returnValue = returnValue || this._reels[i].status !== SLTReelSprite.STOP;
    }
    return returnValue;
};

Scene_SlotMachine.prototype.isWinCounting = function() {
    return this._winCoin > 0;
};

Scene_SlotMachine.prototype.createHelpWindow = function() {
    Scene_MenuBase.prototype.createHelpWindow.call(this);
    this._helpWindow.y = Graphics.boxHeight - this._helpWindow.height;
};

Scene_SlotMachine.prototype.createInstruction = function () {
    this._instructionWindow = new Window_SlotInstruction(0, 0, Graphics.boxWidth, 26 * 6 + 18 * 2);
    this._instructionWindow.setOdds(odds);
    this.addWindow(this._instructionWindow);
};

Scene_SlotMachine.prototype.createSlotMachine = function () {
    this._slotMachineWindow = new Window_SlotMachine(0, this._instructionWindow.height, Graphics.boxWidth, 200);
    this._slotMachineWindow.coin = this._coin;
    this._slotMachineWindow.bet = this._bet;
    this.addWindow(this._slotMachineWindow);
};

Scene_SlotMachine.prototype.createSlotCommand = function () {
    this._slotCommandWindow = new Window_SlotCommand(0, 0);
    this._slotCommandWindow.setHandler('bet', this.betCommand.bind(this));
    this._slotCommandWindow.setHandler('spin', this.spinCommand.bind(this));
    this._slotCommandWindow.setHandler('cancel', this.cancelCommand.bind(this));
    this.addWindow(this._slotCommandWindow);
    this._slotCommandWindow.y = this._helpWindow.y - this._slotCommandWindow.height;
};

Scene_SlotMachine.prototype.createReplayCommand = function () {
    this._replayCommandWindow = new Window_ReplayCommand(0, 0);
    this._replayCommandWindow.setHandler('yes', this.replayCommand.bind(this));
    this._replayCommandWindow.setHandler('no', this.cancelCommand.bind(this));
    this._replayCommandWindow.setHandler('cancel', this.cancelCommand.bind(this));
    this.addWindow(this._replayCommandWindow);
    this._replayCommandWindow.x = Graphics.boxWidth - this._replayCommandWindow.width;
    this._replayCommandWindow.y = this._helpWindow.y - this._replayCommandWindow.height;
};

Scene_SlotMachine.prototype.createReels = function () {
    this._reelBitmap = ImageManager.loadBitmap("img/slotmachine/", "reel");
    this._reels = [];
    for (var i = 0; i < 5; i++) {
        var sprite = new SLTReelSprite(new Bitmap(116, 54 * 18 * 3));
        this._reels.push(sprite);
        sprite.x = 110 + i * 120;
        sprite.y = 222;
        sprite.setSpinEndFrame(SLTReelSprite.FRAME_SPIN + i * 40);
        sprite.setFrame(0, 0, 116, 54 * 3);
        this.addChild(sprite);
    }
};

Scene_SlotMachine.prototype.createBetLine = function () {
    var bitmap = ImageManager.loadBitmap("img/slotmachine/", "line_base");
    this._betLine = new LotLineSprite(bitmap);
    this._betLine.x = 43;
    this._betLine.y = 227;
    this._betLine.clear();
    this.addChild(this._betLine);
};

Scene_SlotMachine.prototype.createScale = function () {
    var bitmap;
    if (scale === 10) {
        bitmap = ImageManager.loadBitmap("img/slotmachine/", "scale_x10");
    }
    else if (scale === 100) {
        bitmap = ImageManager.loadBitmap("img/slotmachine/", "scale_x100");
    }
    else {
        bitmap = ImageManager.loadBitmap("img/slotmachine/", "scale_x1");
    }
    this._scale = new Sprite(bitmap);
    this._scale.x = 719;
    this._scale.y = 212;
    this.addChild(this._scale);
};

Scene_SlotMachine.prototype.cancelCommand = function () {
    this._bet = 0;
    this.refreshStatus();
    setCoin(this._coin);
    this.popScene();
};

Scene_SlotMachine.prototype.betCommand = function () {
    if (this._bet < 3) {
        this._bet++;
        this._slotCommandWindow.enableSpin();
    }
    if (this._bet > 2) {
        this._slotCommandWindow.disableBet();
    }
    if (this._coin - this._bet * scale