//=============================================================================
// Neko Engine Plugins - Gender
// NEK_Gender.js
// Version: 1.00
//=============================================================================

var Imported = Imported || {};
Imported.NEK_Gender = true;

var Neko = Neko || {};
Neko.Gender = Neko.Gender || {};

//=============================================================================
/*:
* @plugindesc Adds gender based message replacements
* @author Nekosune
*
*
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* This plugin will let you have gender specific code for a player, useful for games that are less party based and more, single player
*
* ============================================================================
* Gender Message Replacements
* ============================================================================
* n = party member
* /GENDER - A Man/A Woman/Non-Binary
* /GENDERM - Men/Women/Non-Binary
* /SPRO - he/she/they
* /OPRO - him/her/them
* /PAPRO - his/her/their
* /PPPRO - his/hers/theirs
* /RPRO - himself/herself/themselves
*
* ============================================================================
* Actor tags
* ============================================================================
* Theese go in the Character's note box
* <gender:male> - male character
* <gender:female> - female character
* <sPronoun:she> - Custom Subject Pronoun
* <oPronoun:her> - Custom Object Pronoun
* <paPronoun:her> - Custom Possesive Adjective
* <ppPronoun:hers> - Custom Possesive Pronoun
* <rPronoun:herself> - Custom Reflexive Pronoun.
*
*/
//=============================================================================

//=============================================================================
// Parameter Variables
//=============================================================================
Neko.Parameters = PluginManager.parameters('NEK_Gender');
Neko.Param = Neko.Param || {};



Window_Base.prototype.convertGenderEscapeCharacters = function(text) {
// \GENDER
text = text.replace(/\GENDER\/gi, function() {
return this.partySingularGenderName(parseInt(arguments));
}.bind(this));
text = text.replace(/\GENDERM\/gi, function() {
return this.partyMultipleGenderName(parseInt(arguments));
}.bind(this));
text = text.replace(/\x1bSPRO\/gi, function() {
return this.subjectPronoun(parseInt(arguments));
}.bind(this));

text = text.replace(/\x1bOPRO\/gi, function() {
return this.objectPronoun(parseInt(arguments));
}.bind(this));

text = text.replace(/\x1bPAPRO\/gi, function() {
return this.possesiveAdjective(parseInt(arguments));
}.bind(this));

text = text.replace(/\x1bPPPRO\/gi, function() {
return this.possesivePronoun(parseInt(arguments));
}.bind(this));

text = text.replace(/\x1bRPRO\/gi, function() {
return this.reflexivePronoun(parseInt(arguments));
}.bind(this));
return text;
};


Neko.Gender.Window_Base_convertEscapeCharacters = Window_Base.prototype.convertEscapeCharacters;
Window_Base.prototype.convertEscapeCharacters = function(text) {
text = Neko.Gender.Window_Base_convertEscapeCharacters.call(this, text);
text = this.convertGenderEscapeCharacters(text);
return text;
};

Window_Base.prototype.reflexivePronoun=function(n)
{
var actor = n >= 1 ? $gameParty.members() : null;
var pronoun=actor ? actor.actor().meta.rPronoun : '';
if(pronoun)
{
return pronoun.trim();
}
var gender=this.partyGender(n)

switch(gender)
{
case "male":
return "himself";
break;
case "female":
return "herself";
break;
default:
return "themselves";
}
}
Window_Base.prototype.possesiveAdjective=function(n)
{
var actor = n >= 1 ? $gameParty.members() : null;
var pronoun=actor ? actor.actor().meta.paPronoun : '';
if(pronoun)
{
return pronoun.trim();
}
var gender=this.partyGender(n)

switch(gender)
{
case "male":
return "his";
break;
case "female":
return "her";
break;
default:
return "their";
}
}

Window_Base.prototype.possesivePronoun=function(n)
{
var actor = n >= 1 ? $gameParty.members() : null;
var pronoun=actor ? actor.actor().meta.ppPronoun : '';
if(pronoun)
{
return pronoun.trim();
}
var gender=this.partyGender(n)

switch(gender)
{
case "male":
return "his";
break;
case "female":
return "hers";
break;
default:
return "theirs";
}
}

Window_Base.prototype.subjectPronoun=function(n)
{
var actor = n >= 1 ? $gameParty.members() : null;
var pronoun=actor ? actor.actor().meta.sPronoun : '';
if(pronoun)
{
return pronoun.trim();
}
var gender=this.partyGender(n)

switch(gender)
{
case "male":
return "he";
break;
case "female":
return "she";
break;
default:
return "they";
}
}

Window_Base.prototype.objectPronoun=function(n)
{
var actor = n >= 1 ? $gameParty.members() : null;
var pronoun=actor ? actor.actor().meta.oPronoun : '';
if(pronoun)
{
return pronoun.trim();
}
var gender=this.partyGender(n)

switch(gender)
{
case "male":
return "him";
break;
case "female":
return "her";
break;
default:
return "them";
}
}

Window_Base.prototype.partySingularGenderName=function(n)
{
var gender=this.partyGender(n)
switch(gender)
{
case "male":
return "a Man";
break;
case "female":
return "a Woman";
break;
default:
return "Non Binary person";
}
}

Window_Base.prototype.partyMultipleGenderName=function(n)
{
var gender=this.partyGender(n)
switch(gender)
{
case "male":
return "Men";
break;
case "female":
return "Women";
break;
default:
return "Non Binary people";
}
}

Window_Base.prototype.partyGender = function(n) {
var actor = n >= 1 ? $gameParty.members() : null;
var gender=actor ? actor.actor().meta.gender.trim() : '';
switch(gender)
{
case "male":
case "boy":
case "man":
return "male";
break;
case "female":
case "woman":
case "girl":
return "female";
break;
default:
return "nonBinary"
}
};