Created
June 12, 2016 20:36
-
-
Save GroupoidKid/2ef2e26ea243d54a06eb90983f214201 to your computer and use it in GitHub Desktop.
Script GM pour MountyHall : ajout d'un lien vers l'Anatrolliseur de Mam'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @author Mam' & Dab' | |
// @description MH game, displays buttons to send info to Anatrolliseur | |
// @include http://games.mountyhall.com/mountyhall/MH_Play/Play_profil2.php | |
// @include http://serv01.mountyhall.com/mountyhall/MH_Play/Play_profil2.php | |
// @include http://mh.fr.nf/mountyhall/MH_Play/Play_profil2.php | |
// @name MountyHall - Mam' & Dab' - Anatrolliseur Complet | |
// @namespace mountyhall.dispas.net | |
// @version 0.0.2.1 | |
// ==/UserScript== | |
window.console.log("Anatrollisation ON"); | |
var | |
urlAnatrolliseur = "http://mountyhall.dispas.net/dynamic/"+ | |
"outils_anatrolliseur.php?anatrolliseur=v8|", | |
race, | |
tour_data, tour_duree, tour_amelio, | |
Caracs = { | |
att:{amelio:-3}, | |
esq:{amelio:-3}, | |
deg:{amelio:-3}, | |
pv: {amelio:-3}, | |
reg:{amelio:-3}, | |
arm:{amelio:-3}, | |
vue:{amelio:-3} | |
}, | |
Magie = { | |
mm:1, | |
rm:1 | |
}, | |
TalentsAnatrolliseur = { | |
// Compétences | |
"Attaque Précise" :"APX", | |
"Baroufle" :"BaroufleX", | |
"Bidouille" :"Bidouille", | |
"Charger" :"Charger", | |
"Connaissance des Monstres" :"CdMX", | |
"Construire un Piège" :"PiegeTYPE", | |
"Contre-Attaquer" :"CAX", | |
"Coup de Butoir" :"CdBX", | |
"Course" :"Course", | |
"Déplacement Eclair" :"DE", | |
"Dressage" :"Dressage", | |
"Ecriture Magique" :"EM", | |
"Frénésie" :"Frenesie", | |
"Golemologie" :"GolemTYPE", | |
"Grattage" :"Grattage", | |
"Hurlement Effrayant" :"Hurlement", | |
"Identification des Champignons":"IdC", | |
"Insultes" :"InsuX", | |
"Lancer de Potions" :"LdP", | |
"Marquage" :"Marquage", | |
"Mélange Magique" :"Melange", | |
"Nécromancie" :"Necro", | |
"Painthure de Guerre" :"PG", | |
"Parer" :"ParerX", | |
"Pistage" :"Pist", | |
"Planter un Champignon" :"Planter", | |
"Réparation" :"Reparation", | |
"Retraite" :"RetraiteX", | |
"RotoBaffe" :"RBX", | |
"S'interposer" :"SInterposerX", | |
"Shamaner" :"Shamaner", | |
// XXX XXX XXX // | |
"Travail de la pierre" :"Miner", | |
// Sortilèges | |
"Analyse Anatomique" :"AA", | |
"Armure Ethérée" :"AE", | |
"Augmentation de l´Attaque" :"AdA", | |
"Augmentation de l´Esquive" :"AdE", | |
"Augmentation des Dégats" :"AdD", | |
"Bulle Anti-Magie" :"BAM", | |
"Bulle Magique" :"BuM", | |
"Explosion" :"Explo", | |
"Faiblesse Passagère" :"FP", | |
"Flash Aveuglant" :"FA", | |
"Glue" :"Glu", | |
"Griffe du Sorcier" :"GdS", | |
"Identification des trésors" :"IdT", | |
"Invisibilité" :"Invi", | |
//"Lévitation" :"", | |
"Précision Magique" :"PreM", | |
"Projection" :"Proj", | |
"Puissance Magique" :"PuiM", | |
"Sacrifice" :"Sacro", | |
//"Sortilège d'Obsidienne" :"", | |
"Télékinésie" :"Telek", | |
"Téléportation" :"TP", | |
"Vision Accrue" :"VA", | |
"Vision lointaine" :"VL", | |
"Voir le Caché" :"VlC", | |
"Vue Troublée" :"VT" | |
}; | |
/* Fonctions utilitaires */ | |
function trim(str) { | |
return str.replace(/(^\s*)|(\s*$)/g,""); | |
} | |
function getValueById(id,defaultValue="") { | |
var node = document.getElementById(id); | |
if(node){ | |
if(node.hasChildNodes()) { | |
return node.childNodes[0].nodeValue; | |
} else { | |
return defaultValue; | |
} | |
} else { | |
window.console.log("Pas d'élément trouvé pour selector=",id); | |
return defaultValue; | |
} | |
} | |
function getNumById(id) { | |
var value = getValueById(id,0); | |
return isNaN(value)?0:Number(value); | |
} | |
/* Ajout de la race */ | |
race = getValueById("race").toLowerCase(); | |
urlAnatrolliseur += "r="+race+"|"; | |
/* Ajout des amélios de DLA */ | |
tour_data = getValueById("tour").match(/\d+/g); | |
tour_duree = 60*tour_data[0]+(tour_data[1]==void(0)?0:Number(tour_data[1])); | |
if(tour_duree>555) { | |
tour_amelio = Math.floor((21-Math.sqrt(8*tour_duree/3-1479))/2); | |
} else { | |
tour_amelio = 10+Math.ceil((555-tour_duree)/2.5); | |
} | |
urlAnatrolliseur += "dla="+tour_amelio+"|"; | |
/* Ajout des amélios & BM de caracs standard */ | |
if(race==="darkling"){Caracs.reg.amelio--;} | |
if(race==="durakuir"){Caracs.pv.amelio-- ;} | |
if(race==="kastar") {Caracs.deg.amelio--;} | |
if(race==="skrim") {Caracs.att.amelio--;} | |
if(race==="tomawak") {Caracs.vue.amelio--;} | |
for(var carac in Caracs) { | |
var | |
base = getNumById(carac), | |
bmp = getNumById(carac+"_p"), | |
bmm = getNumById(carac+"_m"); | |
if(carac=="pv") { | |
base=isNaN(base)?-Caracs[carac].amelio:Math.floor(base/10); | |
} else { | |
base=isNaN(base)?-Caracs[carac].amelio:base; | |
} | |
Caracs[carac].amelio += base; | |
Caracs[carac].bmp = isNaN(bmp)?0:bmp; | |
Caracs[carac].bmm = isNaN(bmm)?0:bmm; | |
urlAnatrolliseur += carac+"="+ | |
Caracs[carac].amelio+","+ | |
Caracs[carac].bmp+","+ | |
Caracs[carac].bmm+"|"; | |
//window.console.log(carac+" OK"); | |
} | |
/* Ajout des caracs magiques */ | |
for(var carac in Magie) { | |
urlAnatrolliseur += carac+"="+getNumById(carac+"_tot")+"|"; | |
} | |
/* Ajout des Talents */ | |
var offset = { | |
"competences":3, | |
"sortileges":2 | |
} | |
for(var type in offset) { | |
var lignes = document.getElementById(type).rows; | |
for(var l=1 ; l<lignes.length ; ++l) { | |
var | |
ligne = lignes[l], | |
nom = trim(ligne.cells[1].getElementsByTagName("a")[0].textContent), | |
niv = trim(ligne.cells[offset[type]].textContent), | |
talent, n; | |
niv = isNaN(niv)?1:niv; | |
//window.console.log(nom,niv); | |
if(TalentsAnatrolliseur[nom]) { | |
talent = TalentsAnatrolliseur[nom]; | |
if(talent.indexOf("X")!=-1) { | |
for(n=1 ; n<=Math.min(niv,10) ; ++n) { | |
urlAnatrolliseur += talent.replace(/X/,n)+"|"; | |
} | |
} else if(talent.indexOf("TYPE")!=-1) { | |
// Je sais pas comment ça se présente | |
} else { | |
urlAnatrolliseur += talent+"|"; | |
} | |
} | |
} | |
} | |
/* Création du lien vers l'Anatrolliseur */ | |
window.console.log("url Anatrolliseur:",urlAnatrolliseur); | |
var | |
link = document.createElement("a"), | |
insertPoint = document.getElementById("id").parentNode.parentNode; | |
link.href = urlAnatrolliseur; | |
link.target = "_blank"; | |
link.appendChild(document.createTextNode("=> Anatrolliseur")); | |
insertPoint.appendChild(link); | |
window.console.log("Anatrollisation OFF"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment