/*:
* @plugindesc Spread cards on the screen and give fortune-telling messages
* @author Eldaym
*
*
* @param cardWidth
* @type number
* @default 120
*
* @param cardHeight
* @type number
* @default 156
*
* @param cardScale
* @type number
* @decimals 3
* @default 1
*
* @param waitOnSpread
* @type number
* @default 30
*
* @param reversalProbability
* @type number
* @default 1
*
* @param cardPictures
* @type file[]
* @dir img/pictures/
* @default ["00_Fool", "01_Magician", "02_High_Priestess", "03_Empress", "04_Emperor", "05_Hierophant", "06_Lovers", "07_Chariot", "08_Strength", "09_Hermit", "10_Wheel_of_Fortune", "11_Justice", "12_Hanged_Man", "13_Death", "14_Temperance", "15_Devil", "16_Tower", "17_Star", "18_Moon", "19_Sun", "20_Judgement", "21_World", "22_Ace_of_Wands", "23_Two_of_Wands", "24_Three_of_Wands", "25_Four_of_Wands", "26_Five_of_Wands", "27_Six_of_Wands", "28_Seven_of_Wands", "29_Eight_of_Wands", "30_Nine_of_Wands", "31_Ten_of_Wands", "32_Page_of_Wands", "33_Knight_of_Wands", "34_Queen_of_Wands", "35_King_of_Wands", "36_Ace_of_Pentacles", "37_Two_of_Pentacles", "38_Three_of_Pentacles", "39_Four_of_Pentacles", "40_Five_of_Pentacles", "41_Six_of_Pentacles", "42_Seven_of_Pentacles", "43_Eight_of_Pentacles", "44_Nine_of_Pentacles", "45_Ten_of_Pentacles", "46_Page_of_Pentacles", "47_Knight_of_Pentacles", "48_Queen_of_Pentacles", "49_King_of_Pentacles", "50_Ace_of_Cups", "51_Two_of_Cups", "52_Three_of_Cups", "53_Four_of_Cups", "54_Five_of_Cups", "55_Six_of_Cups", "56_Seven_of_Cups", "57_Eight_of_Cups", "58_Nine_of_Cups", "59_Ten_of_Cups", "60_Page_of_Cups", "61_Knight_of_Cups", "62_Queen_of_Cups", "63_King_of_Cups", "64_Ace_of_Swords", "65_Two_of_Swords", "66_Three_of_Swords", "67_Four_of_Swords", "68_Five_of_Swords", "69_Six_of_Swords", "70_Seven_of_Swords", "71_Eight_of_Swords", "72_Nine_of_Swords", "73_Ten_of_Swords", "74_Page_of_Swords", "75_Knight_of_Swords", "76_Queen_of_Swords", "77_King_of_Swords"]
*
* @param interpretationTexts
* @type text[][]
* @default ["[\"In the past, \",\"There was a time when \",\"Before, \"]","[\"you were often dealt with unfairly\",\"you had someone who meant a lot to you\",\"you cared more than you do now\"]","[\".\\\\. Now, \",\".\\\\. Today, \"]","[\"you should realize things aren't so bad\",\"life is presenting you with great opportunities you are choosing to ignore\",\"you should remember to not let your past haunt you\",\"you need to take life more seriously\",\"people give you better advice than you realize\",\"you give lots of advice but never take any\"]","[\".\\\\. Someday, \",\".\\\\. In the future, \",\".\\\\. Later, \"]","[\"you'll realize your mistakes and it will be too late\",\"you'll regret the choice you aren't making\",\"you'll live life just fine no matter what anybody thinks\",\"you'll know your mom was right sometimes\",\"you'll realize you love someone and it will be too late\"]","[\".\"]"]
*
* Based on http://orteil.dashnet.org/randomgen/?gen=wzTkj6Qg
*
* @help
*
*
*
* This plugin adds four plugins commands to be used in your events:
*
* 1. TarotShuffle
* This command just shuffles the tarot deck. No arguments.
*
* 2. TarotClear
* Clear the cards on the screen
*
* 3. TarotInterpretation
* Display a message with a random fortune telling.
* I suggest you to use a message plugin with wordwrap support (eg Yanfly Message Core),
* because the generated messages are big.
*
* 4. TarotSpreadCard <X> <Y> <R>
*
* This is the main command to be used. This command will display a card on the position X, Y.
* Please note that X and Y use the card height as units, not pixels.
*
* To display the Celtic Cross spread, use the following sequence:
*
* TarotShuffle
* TarotSpreadCard 2 2 0
* TarotSpreadCard 2 2 90
* TarotSpreadCard 2 3 0
* TarotSpreadCard 1 2 0
* TarotSpreadCard 2 1 0
* TarotSpreadCard 3 2 0
* TarotSpreadCard 4 4 0
* TarotSpreadCard 4 3 0
* TarotSpreadCard 4 2 0
* TarotSpreadCard 4 1 0
* TarotInterpretation
* TarotClear
*
*/
(function() {
var params = PluginManager.parameters('ELD_Tarot');
function shuffle(a) {
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
}
var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
alias_Game_Interpreter_pluginCommand.call(this, command, args);
if (command == 'TarotClear' || command == 'TarotShuffle') {
if (this._tarotCount && this._tarotCount > 0) {
for (var i = 0; i < this._tarotCount; i++) {
$gameScreen.erasePicture(i + 1);
}
}
this._tarotCount = 0;
}
if (command == 'TarotShuffle' || (command == 'TarotSpreadCard' && !this._tarotCards)) {
console.log('shuffling cards')
if (!this._tarotCards) {
this._tarotCards = eval(params['cardPictures']);
}
if (this._tarotCount > 0) {
for (var i = 0; i < this._tarotCount; i++) {
$gameScreen.erasePicture(i + 1);
}
this._tarotCount = 0;
}
this._tarotCards = shuffle(this._tarotCards);
}
if (command == 'TarotSpreadCard') {
if (!this._tarotCount) {
this._tarotCount = 0;
}
this._tarotCount++;
var cardScale = parseFloat(params['cardScale']);
var h = parseInt(params['cardHeight']) * cardScale;
var w = (parseInt(params['cardWidth']) * cardScale);
var x = parseFloat(args[0]) * Math.max(w, h);
var y = (parseFloat(args[1]) - 0.5) * h;
var angle = parseInt(args[2]);
$gameScreen.showPicture(this._tarotCount, this._tarotCards[this._tarotCount], 1, x, y, cardScale*100, cardScale*100, 255, 0);
var realpic = $gameScreen.picture(this._tarotCount);
realpic._z += this._tarotCount;
if (angle != 0) {
realpic._angle = angle;
}
var revprob = parseInt(params['reversalProbability']);
if ((revprob > 0) && (Math.randomInt(100) <= revprob)) {
realpic._angle = angle + 180;
}
this.wait(parseInt(params['waitOnSpread']));
}
if (command == 'TarotInterpretation') {
var texts = eval(params['interpretationTexts']);
console.log(texts);
var msg = '';
var s = '';
for (var i = 0; i < texts.length; i++) {
texts[i] = eval(texts[i]);
var j = Math.randomInt(texts[i].length);
s = texts[i][j];
msg = msg + s;
}
$gameMessage.add(msg);
this.setWaitMode('message');
}
}
})();