사용자:Senouis/RPGinCity.js: 두 판 사이의 차이

리버티게임, 모두가 만들어가는 자유로운 게임
imported>Senouis
잔글편집 요약 없음
편집 요약 없음
 
(다른 사용자 한 명의 중간 판 13개는 보이지 않습니다)
1번째 줄: 1번째 줄:
const usernameStr = mw.user.getName();
function RPGinCity(){
const currentpage = mw.config.get("wgPageName");
var usernameStr = mw.user.getName();
console.log(currentpage);
var currentpage = mw.config.get("wgPageName");
 
var pagenode = currentpage.split('/');
 
console.log("사용자:"+ usernameStr + "/RPG_in_City.json");
function RPGinCity_Title() {
if (pagenode[0] !== "RPG_in_City"){
let startbuttondiv = document.getElementById("RPGinCityStart");
if (currentpage !== "사용자:"+ usernameStr + "/RPG_in_City.json") {
let loadbuttondiv =  document.getElementById("RPGinCityLoad");
console.log("Current page is "+ currentpage +", not playing RPG in City");
if (startbuttondiv !== null && loadbuttondiv !== null){
return;
if (usernameStr === null) {
}
startbuttondiv.innerHTML = "<p>로그인이 필요합니다</p>";
}
var fullbasepagename = "";
for (var node = 0 ; node < pagenode.length - 2; node++){
fullbasepagename = fullbasepagename + pagenode[node] + "/";
}
fullbasepagename = fullbasepagename + pagenode[pagenode.length - 2];
console.log(fullbasepagename);
function RPGinCity_Title() {
var startbuttondiv = document.getElementById("RPGinCityStart");
var loadbuttondiv =  document.getElementById("RPGinCityLoad");
if (startbuttondiv !== null && loadbuttondiv !== null){
if (usernameStr === null) {
startbuttondiv.innerHTML = "<p>로그인이 필요합니다</p>";
} else {
var UserDBTitle = new mw.Title("사용자:"+usernameStr+"/RPG in City.json");
startbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText(),{action: 'edit', preload : '틀:RPG_in_City_DB_양식', summary:'생성'})+ "\">시작하기</a></big></p>";
loadbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText())+ "\">계속하기</a></big></p>";
}
}
}
function RPGinCity_GoToCheckpoint () {
var JSONDatalist = document.getElementsByClassName("mw-json-value");
if (currentpage === ("사용자:"+usernameStr+"/RPG_in_City.json") && JSONDatalist.length !== 0) {
var MWContent = document.getElementById("mw-content-text");
var GotoLink= document.createElement("a");
GotoLink.href = mw.util.getUrl((JSONDatalist[0].innerText.substring(1, JSONDatalist[0].innerText.length-1)));
console.log(GotoLink.href);
GotoLink.innerText = "게임 계속하기";
MWContent.appendChild(GotoLink);
}
}
function RPGinCity_pushFightInfo(targetUri, Mhp, Ehp, Jam, PJam, BanBomb, Etype, Elevel, Turn) {
targetUri.extend({mhp:Mhp});
targetUri.extend({ehp:Ehp});
targetUri.extend({j:Jam});
targetUri.extend({bj:PJam});
targetUri.extend({bb:BanBomb});
targetUri.extend({etype:Etype});
targetUri.extend({elevel:Elevel});
targetUri.extend({turn:Turn});
return targetUri;
}
function RPGinCity_HandleBattle(jsonfile) {
var Battlelink = new mw.Uri(window.location.href);
console.log("building battle phase...");
var queryparams = Battlelink.query;
// 이제 필요한 값을 구해 화면에 표시한다.
// 플레이어 체력부터...
var mhp = 0;
var playerhealth = document.getElementById("playerhealth");
if (isNaN(queryparams.mhp)) {
mhp = jsonfile.체력;
} else {
} else {
let UserDBTitle = new mw.Title("사용자:"+usernameStr+"/RPG in City.json");
mhp = queryparams.mhp; // mhp는 이전 문서의 값을 받는다.
startbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText(),{action: 'edit', preload : '틀:RPG_in_City_DB_양식', summary:'생성'})+ "\">시작하기</a></big></p>";
loadbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText())+ "\">계속하기</a></big></p>";
 
}
}
playerhealth.innerText = mhp;
//적의 레벨
var enemylevel = document.getElementById("enemylevel");
enemylevel.innerText = queryparams.elevel; // elevel는 항상 undefined이 아니다.
//적의 체력
var enemyhealth = document.getElementById("enemyhealth");
enemyhealth.innerText = queryparams.ehp; // ep는 항상 undefined이 아니다.
//공격 페이즈
var nextPhaseUri = new mw.Uri("https://liberty.banipest.com/index.php?title="+currentpage);
var attackEnemy = document.getElementById("attackEnemy");
var attackPower = Math.round(Math.random() * jsonfile.레벨*3) + jsonfile.무기;
var attackEnemyUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, (queryparams.ehp - attackPower) >= 0?queryparams.ehp - attackPower : 0, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
if (attackEnemy !== undefined && attackEnemy !== null)attackEnemy.innerHTML="<a href=\"" + attackEnemyUri.toString() + "\">그냥 공격!</a>";
var useJam = document.getElementById("useJam");
var useJamUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), jsonfile.체력, queryparams.ehp, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
if (useJam !== undefined && useJam !== null)useJam.innerHTML="<a href=\"" + useJamUri.toString() + "\">잼으로 회복!</a>";
var usePJ = document.getElementById("usePJ");
var usePJUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, queryparams.ehp > 20 ? queryparams.ehp - 20 : 0, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
if (usePJ !== undefined && usePJ !== null)usePJ.innerHTML="<a href=\"" + usePJUri.toString() + "\">배쨈 열기!</a>";
var useBanbomb = document.getElementById("useBanbomb");
var useBanbombUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, queryparams.ehp/2, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
if (useBanbomb !== undefined && useBanbomb !== null)useBanbomb.innerHTML="<a href=\"" + useBanbombUri.toString() + "\">차단폭탄!</a>";
//방어 페이즈
var Blocking = document.getElementById("Block");
var BlockingUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp- Math.round(Math.random() * queryparams.elevel * 0.75), queryparams.ehp , queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 1);
if (Blocking !== undefined && Blocking !== null)Blocking.innerHTML="<a href=\"" + BlockingUri.toString() + "\">방어</a>";
var FailRunning = document.getElementById("FailRunning");
var FailRunningUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp - Math.round(Math.random() * queryparams.elevel), queryparams.ehp, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 1);
if (FailRunning !== undefined && FailRunning !== null)FailRunning.innerHTML="<a href=\"" + FailRunningUri.toString() + "\">도망치자!</a>";
var RunFromEnemy = document.getElementById("RunFromEnemy");
var MustKill = document.getElementById("mustKill");
if (RunFromEnemy !== undefined && RunFromEnemy !== null && (MustKill === undefined || MustKill === null))RunFromEnemy.style.visibility = "visible";
}
}
}
 
function RPGinCity_SaveHandle(saveGameHandle) {
function RPGinCity_GoToCheckpoint () {
var api = new mw.Api();
let JSONDatalist = document.getElementsByClassName("mw-json-value");
var Templink = new mw.Uri(window.location.href);
if (currentpage === ("사용자:"+usernameStr+"/RPG_in_City.json") && JSONDatalist.length !== 0) {
var queryparams = Templink.query;
let MWContent = document.getElementById("mw-content-text");  
switch (saveGameHandle.innerText){
let GotoLink= document.createElement("a");
case "서브퀘스트완료":
GotoLink.href = mw.util.getUrl((JSONDatalist[0].innerText.substring(1, JSONDatalist[0].innerText.length-1)));
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
console.log(GotoLink.href);
var jsondata = JSON.parse(revision.content);
GotoLink.innerText = "게임 계속하기";
jsondata.추가1 = 0;
MWContent.appendChild(GotoLink);
jsondata.최근페이지 = fullbasepagename;
return {text: JSON.stringify(jsondata), summary: "서브퀘스트완료"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
case "서브퀘스트수행":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
var jsondata = JSON.parse(revision.content);
var questID = document.getElementById("questID");
if (questID !== undefined && questID !== null){
jsondata.추가1 = parseInt(questID.innerText);
jsondata.최근페이지 = fullbasepagename;
}
return {text: JSON.stringify(jsondata), summary: "서브퀘스트수행"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
case "메인퀘스트수행":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
var jsondata = JSON.parse(revision.content);
var mainQuestPoint = document.getElementById("mainQuestPoint");
if (mainQuestPoint !== undefined && mainQuestPoint !== null) jsondata.최근페이지 = mainQuestPoint.innerText;
var questID = document.getElementById("questID");
if (questID !== undefined && questID !== null)jsondata.추가2 = parseInt(questID.innerText);
return {text: JSON.stringify(jsondata), summary: "메인퀘스트수행"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
case "동부요금지불":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
var jsondata = JSON.parse(revision.content);
jsondata.돈 -= 500*1;
jsondata.추가2 = 5*1; // force to parse it a number
jsondata.최근페이지 = "RPG in City/만남의 광장";
return {text: JSON.stringify(jsondata), summary: "동부요금지불"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
case "전투승리":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
var jsondata = JSON.parse(revision.content);
jsondata.체력 = parseInt(queryparams.mhp);
jsondata.경험치 += queryparams.elevel*4;
jsondata.돈 += queryparams.elevel*5;
jsondata.최근페이지 = currentpage.substring(0, currentpage.length-3);
return {text: JSON.stringify(jsondata), summary: "전투승리"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
case "레벨업":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
var jsondata = JSON.parse(revision.content);
jsondata.레벨 += (jsondata.경험치 - jsondata.경험치 % 128)/128;
jsondata.경험치 = jsondata.경험치 % 128;
return {text: JSON.stringify(jsondata), summary: "레벨업"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
case "회복":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
var jsondata = JSON.parse(revision.content);
jsondata.체력 = jsondata.레벨 * 16;
return {text: JSON.stringify(jsondata), summary: "회복"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
case "결제":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
var jsondata = JSON.parse(revision.content);
jsondata.잼 += queryparams.j*1;
jsondata.배쨈 += queryparams.bj*1;
jsondata.차단폭탄 += queryparams.bb*1;
jsondata.무기 += queryparams.weapon*1;
jsondata.돈 -= 50* queryparams.j + 75*queryparams.bj + 150*queryparams.bb + 1000 * queryparams.weapon;
jsondata.최근페이지 = currentpage.substring(0, currentpage.length-3);
return {text: JSON.stringify(jsondata), summary: "결제"};
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
default:
    alert( 'No proper parameters' );
break;
}
}
}
}
 
function RPGinCity_HandleStore(jsondata, storeNumber) {
function RPGinCity_pushFightInfo(targetUri, Mhp, Ehp, Jam, PJam, BanBomb, Etype, Elevel, Turn) {
var i = storeNumber;
targetUri.extend({mhp:Mhp});
var Jam = document.getElementsByClassName("JamAmount")[i];
targetUri.extend({ehp:Ehp});
if (Jam !== undefined && Jam !== null && Jam.innerText === "") Jam.innerText = "0";
targetUri.extend({j:Jam});
var PearJam = document.getElementsByClassName("PearJamAmount")[i];
targetUri.extend({bj:PJam});
if (PearJam !== undefined && PearJam !== null && PearJam.innerText === "") PearJam.innerText = "0";
targetUri.extend({bb:BanBomb});
var BB = document.getElementsByClassName("BanBombAmount")[i];
targetUri.extend({etype:Etype});
if (BB !== undefined && BB !== null && BB.innerText === "") BB.innerText = "0";
targetUri.extend({elevel:Elevel});
var WeaponLevelUp = document.getElementsByClassName("WeaponLevelUp")[i];
targetUri.extend({turn:Turn});
if (WeaponLevelUp !== undefined && WeaponLevelUp !== null && WeaponLevelUp.innerText === "") WeaponLevelUp.innerText = "0";
return targetUri;
var BuyButton = document.getElementsByClassName("BuyButton")[i];
}
if (BuyButton !== undefined && BuyButton !== null) {
 
if (50 * parseInt(Jam.innerText) + 75 * parseInt(PearJam.innerText) + 150* parseInt(BB.innerText) + 1000*parseInt(WeaponLevelUp.innerText) > jsondata.돈) {
function RPGinCity_HandleBattle(jsonfile) {
BuyButton.innerText = "돈이 부족하다. 나가서 돈을 구해오자.";
let Battlelink = new mw.Uri(window.location.href);
}
console.log("building battle phase...");
BuyButton.style.visibility = "visible";
let queryparams = Battlelink.query;
}
// 이제 필요한 값을 구해 화면에 표시한다.
// 플레이어 체력부터...
let mhp = 0;
let playerhealth = document.getElementById("playerhealth");
if (isNaN(queryparams.mhp)) {
mhp = jsonfile.체력;
} else {
mhp = queryparams.mhp; // mhp는 이전 문서의 값을 받는다.
}
}
playerhealth.innerText = mhp;
//적의 레벨
function RPGinCity_Callback_fetchUserInformation(jsonfile) {
let enemylevel = document.getElementById("enemylevel");
// 정보 틀 관련
enemylevel.innerText = queryparams.elevel; // elevel는 항상 undefined이 아니다.
var playerinfo = document.getElementsByClassName("Playerinfo");
//적의 체력
var LevelUpButton = document.getElementById("LevelUp");
let enemyhealth = document.getElementById("enemyhealth");
if ( playerinfo !== undefined && playerinfo !== null && playerinfo.length > 0) {
enemyhealth.innerText = queryparams.ehp; // ep는 항상 undefined이 아니다.
playerinfo[0].innerText = jsonfile['레벨'];
//공격 페이즈
playerinfo[1].innerText = jsonfile['체력'];
let nextPhaseUri = new mw.Uri("https://libertygame.miraheze.org/w/index.php?title="+currentpage);
playerinfo[2].innerText = jsonfile['경험치'];
let attackEnemy = document.getElementById("attackEnemy");
playerinfo[3].innerText = jsonfile['잼'];
let attackPower = Math.round(Math.random() * jsonfile.레벨*3) + jsonfile.무기;
playerinfo[4].innerText = jsonfile['배쨈'];
let attackEnemyUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, (queryparams.ehp - attackPower) >= 0?queryparams.ehp - attackPower : 0, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
playerinfo[5].innerText = jsonfile['차단폭탄'];
if (attackEnemy !== undefined && attackEnemy !== null)attackEnemy.innerHTML="<a href=\"" + attackEnemyUri.toString() + "\">그냥 공격!</a>";
playerinfo[6].innerText = jsonfile['돈'];
let useJam = document.getElementById("useJam");
playerinfo[7].innerText = jsonfile['무기'];
let useJamUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), jsonfile.체력, queryparams.ehp, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
if (LevelUpButton !== undefined && LevelUpButton !== null && jsonfile.경험치 > 128 && jsonfile.레벨 + jsonfile.경험치 /128 <= 50) {
if (useJam !== undefined && useJam !== null)useJam.innerHTML="<a href=\"" + useJamUri.toString() + "\">잼으로 회복!</a>";
LevelUpButton.innerHTML = "<a href= \"https://liberty.banipest.com/index.php/RPG_in_City/레벨_업\">레벨 업!</a>";
let usePJ = document.getElementById("usePJ");
let usePJUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, queryparams.ehp > 20 ? queryparams.ehp - 20 : 0, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
if (usePJ !== undefined && usePJ !== null)usePJ.innerHTML="<a href=\"" + usePJUri.toString() + "\">배쨈 열기!</a>";
let useBanbomb = document.getElementById("useBanbomb");
let useBanbombUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, queryparams.ehp/2, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
if (useBanbomb !== undefined && useBanbomb !== null)useBanbomb.innerHTML="<a href=\"" + useBanbombUri.toString() + "\">차단폭탄!</a>";
//방어 페이즈
let Blocking = document.getElementById("Block");
let BlockingUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp- Math.round(Math.random() * queryparams.elevel * 0.75), queryparams.ehp , queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 1);
if (Blocking !== undefined && Blocking !== null)Blocking.innerHTML="<a href=\"" + BlockingUri.toString() + "\">방어</a>";
let FailRunning = document.getElementById("FailRunning");
let FailRunningUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp - Math.round(Math.random() * queryparams.elevel), queryparams.ehp, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 1);
if (FailRunning !== undefined && FailRunning !== null)FailRunning.innerHTML="<a href=\"" + FailRunningUri.toString() + "\">도망치자!</a>";
let RunFromEnemy = document.getElementById("RunFromEnemy");
let MustKill = document.getElementById("mustKill");
if (RunFromEnemy !== undefined && RunFromEnemy !== null && (MustKill === undefined || MustKill === null))RunFromEnemy.style.visibility = "visible";
}
 
function RPGinCity_SaveHandle(saveGameHandle) {
let Templink = new mw.Uri(window.location.href);
let queryparams = Templink.query;
switch (saveGameHandle.innerText){
case "서브퀘스트완료":
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
let jsondata = JSON.parse(revision.content);
jsondata.추가1 = 0;
return {text: JSON.stringify(jsondata), summary: "서브퀘스트완료"};
}
}
).then(function () {
}
    alert( 'Saved!' );
// RPG in City/집 쉬기 기능
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
var RestingInHouse = document.getElementById("House");
});
if (RestingInHouse !== undefined && RestingInHouse != null) {
break;
if (jsonfile.체력 < jsonfile.레벨 * 16){
case "서브퀘스트수행":
RestingInHouse.innerHTML = "너는 한숨 자고 개운한 마음으로 이곳을 나가려고 한다.\n<a href=\"https://liberty.banipest.com/index.php/RPG_in_City/"+currentpage+"/회복\">쉬기</a>";
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
let jsondata = JSON.parse(revision.content);
let questID = document.getElementById("questID");
if (questID !== undefined && questID !== null)jsondata.추가1 = parseInt(questID.innerText);
return {text: JSON.stringify(jsondata), summary: "서브퀘스트수행"};
}
}
).then(function () {
RestingInHouse.style.visibility = "visible";
    alert( 'Saved!' );
}
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
// RPG in City 전투 관련 스크립트
});
var inBattle = document.getElementById("Fight");
break;
if (inBattle !== undefined && inBattle !== null){
case "메인퀘스트수행":
RPGinCity_HandleBattle(jsonfile);
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
} // 전투 틀 처리 완료
let jsondata = JSON.parse(revision.content);
// 일반적인 상점(문서 내에 단 한 개 존재) 처리
let mainQuestPoint = document.getElementById("mainQuestPoint");
var storeHandle = document.getElementById("RiCStore");
if (mainQuestPoint !== undefined && mainQuestPoint !== null) jsondata.최근페이지 = mainQuestPoint.innerText;
if (storeHandle !== undefined && storeHandle !== null){
let questID = document.getElementById("questID");
RPGinCity_HandleStore(jsonfile, 0);
if (questID !== undefined && questID !== null)jsondata.추가2 = parseInt(questID.innerText);
}
return {text: JSON.stringify(jsondata), summary: "메인퀘스트수행"};
//동부2구역구 - 중부구역구 이동 가능 여부 처리
var DowntownRoadOpen = document.getElementById("DowntownRoad");
if (DowntownRoadOpen !== undefined && DowntownRoadOpen !== null) {
if (jsonfile.추가2 < 60) {
DowntownRoadOpen.innerText = "이런!!! 다운타운 로드는 반달로 인해 막혀있다.";
}
}
).then(function () {
DowntownRoadOpen.style.visibility = "visible";
    alert( 'Saved!' );
}
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
//남부 1구역구 메인퀘스트
});
var south1st = document.getElementById("south1st");
break;
if (south1st !== undefined && south1st !== null) {
case "동부요금지불":
var displaypart;
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
if (jsonfile.추가2 < 10){
let jsondata = JSON.parse(revision.content);
displaypart = document.getElementById("beforeBossfight");
jsondata.돈 -= 500*1;
displaypart.style.display = "block";
jsondata.추가2 = 5*1; // force to parse it a number
} else {
jsondata.최근페이지 = "RPG in City/만남의 광장"
displaypart = document.getElementById("afterBossfight");
return {text: JSON.stringify(jsondata), summary: "동부요금지불"};
displaypart.style.display = "block";
}
}
).then(function () {
}
    alert( 'Saved!' );
//중부구역구
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
var toWest = document.getElementById("toWest");
});
if (toWest !== undefined && toWest !== null) {
break;
if (jsonfile.추가2 < 25) {
case "전투승리":
toWest.innerText = "서부 구역구 방향으로 가기 - <중부 구역구가 파괴된 시점에서 서부 구역구를 분리하는 장벽은 강력한 반달러들로 인해 봉쇄 상태를 유지하고 있다>";
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
let jsondata = JSON.parse(revision.content);
jsondata.체력 = parseInt(queryparams.mhp);
jsondata.경험치 += queryparams.elevel*4;
jsondata.돈 += queryparams.elevel*5;
jsondata.최근페이지 = currentpage.substring(0, currentpage.length-3);
return {text: JSON.stringify(jsondata), summary: "전투승리"};
}
}
).then(function () {
toWest.style.visibility = "visible";
    alert( 'Saved!' );
}
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
var toCentralOffice = document.getElementById("toCentralOffice");
});
if (toCentralOffice !== undefined && toCentralOffice !== null) {
break;
if (jsonfile.추가2 < 40) {
case "레벨업":
toCentralOffice.innerText = "시청으로 들어가기 - < 시청에 들어갈 방법을 찾아야 한다 >";
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
let jsondata = JSON.parse(revision.content);
jsondata.레벨 += (jsondata.경험치 - jsondata.경험치 % 128)/128
jsondata.경험치 = jsondata.경험치 % 128;
return {text: JSON.stringify(jsondata), summary: "레벨업"};
}
}
).then(function () {
toCentralOffice.style.visibility = "visible";
    alert( 'Saved!' );
}
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
var peacefulCentral = document.getElementById("peacefulCentral");
});
var dangerousCentral = document.getElementById("dangerousCentral");
break;
if (peacefulCentral !== undefined && peacefulCentral !== null && dangerousCentral !== undefined && dangerousCentral !== null) {
case "회복":
if (jsonfile.추가2 >= 70) {
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
peacefulCentral.style.visibility = "visible";
let jsondata = JSON.parse(revision.content);
} else {
jsondata.체력 = jsondata.레벨 * 16;
dangerousCentral.style.visibility = "visible";
return {text: JSON.stringify(jsondata), summary: "회복"};
}
}
).then(function () {
}
    alert( 'Saved!' );
// 중부 구역구 대피소 퀘스트
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
var rescuePeregirl = document.getElementsByClassName("rescuePeregirl");
});
if (rescuePeregirl !== undefined && rescuePeregirl !== null && rescuePeregirl.length > 0) {
break;
if (jsonfile.추가2 < 15) {
case "결제":
rescuePeregirl[1].remove();
new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
rescuePeregirl[0].style.display = "block";
let jsondata = JSON.parse(revision.content);
} else if (jsonfile.추가2 === 20) {
jsondata.잼 += queryparams.j*1;
rescuePeregirl[0].remove();
jsondata.배쨈 += queryparams.bj*1;
rescuePeregirl[0].style.display = "block";
jsondata.차단폭탄 += queryparams.bb*1;
} else {
jsondata.무기 += queryparams.weapon*1;
rescuePeregirl[0].remove();
jsondata.돈 -= 50* queryparams.j + 75*queryparams.bj + 150*queryparams.bb + 1000 * queryparams.weapon;
rescuePeregirl[0].remove();
jsondata.최근페이지 = currentpage.substring(0, currentpage.length-3);
rescuePeregirl[0].style.display = "block";
return {text: JSON.stringify(jsondata), summary: "결제"};
}
}
).then(function () {
    alert( 'Saved!' );
    saveGameHandle.innerHTML="<a href=\"https://libertygame.miraheze.org/w/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
});
break;
default:
    alert( 'No proper parameters' );
break;
}
}
function RPGinCity_HandleStore(jsondata, storeNumber) {
let i = storeNumber;
let Jam = document.getElementsByClassName("JamAmount")[i];
if (Jam !== undefined && Jam !== null && Jam.innerText === "") Jam.innerText = "0";
let PearJam = document.getElementsByClassName("PearJamAmount")[i];
if (PearJam !== undefined && PearJam !== null && PearJam.innerText === "") PearJam.innerText = "0";
let BB = document.getElementsByClassName("BanBombAmount")[i];
if (BB !== undefined && BB !== null && BB.innerText === "") BB.innerText = "0";
let WeaponLevelUp = document.getElementsByClassName("WeaponLevelUp")[i];
if (WeaponLevelUp !== undefined && WeaponLevelUp !== null && WeaponLevelUp.innerText === "") WeaponLevelUp.innerText = "0";
let BuyButton = document.getElementsByClassName("BuyButton")[i];
if (BuyButton !== undefined && BuyButton !== null) {
if (50 * parseInt(Jam.innerText) + 75 * parseInt(PearJam.innerText) + 150* parseInt(BB.innerText) + 1000*parseInt(WeaponLevelUp.innerText) > jsondata.돈) {
BuyButton.innerText = "돈이 부족하다. 나가서 돈을 구해오자.";
}
}
BuyButton.style.visibility = "visible";
var meetPeregirl = document.getElementsByClassName("meetPeregirl");
}
if (meetPeregirl !== undefined && meetPeregirl !== null && meetPeregirl.length > 0) {
}
if (jsonfile.추가2 < 20) {
 
meetPeregirl[0].style.display = "block";
function RPGinCity_Callback_fetchUserInformation(jsonfile) {
} else {
let basepagename = document.getElementById("basepagename");
meetPeregirl[0].remove();
// 정보 틀 관련
meetPeregirl[0].style.display = "block";
let playerinfo = document.getElementsByClassName("Playerinfo");
}
let LevelUpButton = document.getElementById("LevelUp");
if ( playerinfo !== undefined && playerinfo !== null && playerinfo.length > 0) {
playerinfo[0].innerText = jsonfile.레벨;
playerinfo[1].innerText = jsonfile.체력;
playerinfo[2].innerText = jsonfile.경험치;
playerinfo[3].innerText = jsonfile.잼;
playerinfo[4].innerText = jsonfile.배쨈;
playerinfo[5].innerText = jsonfile.차단폭탄;
playerinfo[6].innerText = jsonfile.돈;
playerinfo[7].innerText = jsonfile.무기;
if (LevelUpButton !== undefined && LevelUpButton !== null && jsonfile.경험치 > 128 && jsonfile.레벨 + jsonfile.경험치 /128 <= 50) {
LevelUpButton.innerHTML = "<a href= \"https://libertygame.miraheze.org/wiki/RPG_in_City/레벨_업\">레벨 업!</a>";
}
}
}
//남부 1구역구 상점, 문서 구조상 좀 구현이 복잡하여 분리한다.
// RPG in City/집 쉬기 기능
var south1stStore = document.getElementsByClassName("south1stStore");
let RestingInHouse = document.getElementById("House");
if (south1stStore !== undefined && south1stStore !== null && south1stStore.length > 0) {
if (RestingInHouse !== undefined && RestingInHouse != null) {
if (jsonfile.추가2 < 10) {
if (jsonfile.체력 < jsonfile.레벨 * 16){
south1stStore[0].style.display = "block";
RestingInHouse.innerHTML = "너는 한숨 자고 개운한 마음으로 이곳을 나가려고 한다.\n<a href=\"https://libertygame.miraheze.org/wiki/RPG_in_City/"+currentpage+"/회복\">쉬기</a>";
RPGinCity_HandleStore(jsonfile, 0);
} else {
south1stStore[1].style.display = "block";
RPGinCity_HandleStore(jsonfile, 1);
}
}
}
RestingInHouse.style.visibility = "visible";
//시청 안의 산토끼 몰매 맞고 가나요~
}
var cityOffice = document.getElementsByClassName("cityOffice");
// RPG in City 전투 관련 스크립트
if (cityOffice !== undefined && cityOffice !== null && cityOffice.length > 0) {
let inBattle = document.getElementById("Fight");
if (jsonfile.추가2 < 70) {
if (inBattle !== undefined && inBattle !== null){  
cityOffice[0].style.display = "block";
RPGinCity_HandleBattle(jsonfile);
} else {
} // 전투 틀 처리 완료
cityOffice[1].style.display = "block";
// 일반적인 상점(문서 내에 단 한 개 존재) 처리
}
let storeHandle = document.getElementById("RiCStore");
if (storeHandle !== undefined && storeHandle !== null){
RPGinCity_HandleStore(jsonfile, 0);
}
//동부2구역구 - 중부구역구 이동 가능 여부 처리
let DowntownRoadOpen = document.getElementById("DowntownRoad");
if (DowntownRoadOpen !== undefined && DowntownRoadOpen !== null) {
if (jsonfile.추가2 < 60) {
DowntownRoadOpen.innerText = "이런!!! 다운타운 로드는 반달로 인해 막혀있다.";
}
}
DowntownRoadOpen.style.visibility = "visible";
var cityOfficeInternal = document.getElementsByClassName("cityOfficeInternal");
}
if (cityOfficeInternal !== undefined && cityOfficeInternal !== null && cityOfficeInternal.length > 0) {
//남부 1구역구 메인퀘스트
if (jsonfile.추가2 >= 65) {
let south1st = document.getElementById("south1st");
cityOfficeInternal[0].style.display = "block";
if (south1st !== undefined && south1st !== null) {
} else {
let displaypart;
cityOfficeInternal[1].style.display = "block";
if (jsonfile.추가2 < 10){
}
displaypart = document.getElementById("beforeBossfight");
displaypart.style.visibility = "visible";
} else {
displaypart = document.getElementById("afterBossfight");
displaypart.style.visibility = "visible";
}
}
}
var cityOffice3F = document.getElementsByClassName("cityOffice3F");
//중부구역구
if (cityOffice3F !== undefined && cityOffice3F !== null && cityOffice3F.length > 0) {
let toWest = document.getElementById("toWest");
if (jsonfile.추가2 >= 65) {
if (toWest !== undefined && toWest !== null) {
cityOffice3F[0].style.display = "block";
if (jsonfile.추가2 < 25) {
} else {
toWest.innerText = "서부 구역구 방향으로 가기 - <중부 구역구가 파괴된 시점에서 서부 구역구를 분리하는 장벽은 강력한 반달러들로 인해 봉쇄 상태를 유지하고 있다>";
cityOffice3F[1].style.display = "block";
}
}
}
toWest.style.visibility = "visible";
var mayorRoom = document.getElementsByClassName("mayorRoom");
}
if (mayorRoom !== undefined && mayorRoom !== null && mayorRoom.length > 0) {
let toCentralOffice = document.getElementById("toCentralOffice");
if (jsonfile.추가2 >= 70) {
if (toCentralOffice !== undefined && toCentralOffice !== null) {
mayorRoom[0].style.display = "block";
if (jsonfile.추가2 < 40) {
} else {
toCentralOffice.innerText = "시청으로 들어가기 - < 시청에 들어갈 방법을 찾아야 한다 >";
mayorRoom[1].style.display = "block";
}
}
}
toCentralOffice.style.visibility = "visible";
// 서브 퀘스트 관련
}
var subQuestContent = document.getElementById("SubQuestContent");
let peacefulCentral = document.getElementById("peacefulCentral");
var parentNode;
let dangerousCentral = document.getElementById("dangerousCentral");
if (subQuestContent !== undefined && subQuestContent !== null){
if (peacefulCentral !== undefined && peacefulCentral !== null && dangerousCentral !== undefined && dangerousCentral !== null) {
parentNode = subQuestContent.parentElement;
if (jsonfile.추가2 >= 70) {
peacefulCentral.style.visibility = "visible";
} else {
dangerousCentral.style.visibility = "visible";
}
}
}
if (parentNode !== undefined && parentNode !== null && subQuestContent !== undefined && subQuestContent !== null) {
// 중부 구역구 대피소 퀘스트
if (jsonfile.추가1 !== 0) {
let rescuePeregirl = document.getElementsByClassName("rescuePeregirl");
parentNode.removeChild( subQuestContent );
if (rescuePeregirl !== undefined && rescuePeregirl !== null && rescuePeregirl.length > 0) {
} else {
if (jsonfile.추가2 < 15) {
subQuestContent.style.display = "block";
rescuePeregirl[1].remove();
}
rescuePeregirl[0].style.display = "block";
} else if (jsonfile.추가2 === 20) {
rescuePeregirl[0].remove();
rescuePeregirl[0].style.display = "block";
} else {
rescuePeregirl[0].remove();
rescuePeregirl[0].remove();
rescuePeregirl[0].style.display = "block";
}
}
}
var subQuestEnd = document.getElementById("SubQuestEnd");
let meetPeregirl = document.getElementsByClassName("meetPeregirl");
if (parentNode !== undefined && parentNode !== null &&subQuestEnd !== undefined && subQuestEnd !== null) {
if (meetPeregirl !== undefined && meetPeregirl !== null && meetPeregirl.length > 0) {
if (jsonfile.추가1 !== 1) {
if (jsonfile.추가2 < 20) {
parentNode.removeChild( subQuestEnd );
meetPeregirl[0].style.display = "block";
} else {
} else {
subQuestEnd.style.display = "block";
meetPeregirl[0].remove();
}
meetPeregirl[0].style.display = "block";
}
}
}
var subQuestNotEnd = document.getElementsByClassName("SubQuestNotEnd");
//남부 1구역구 상점, 문서 구조상 좀 구현이 복잡하여 분리한다.
if (parentNode !== undefined && parentNode !== null && subQuestNotEnd !== undefined && subQuestNotEnd !== null) {
let south1stStore = document.getElementsByClassName("south1stStore");
if (jsonfile.추가1 <2) {
if (south1stStore !== undefined && south1stStore !== null && south1stStore.length > 0) {
parentNode.removeChild( subQuestNotEnd[0] );
if (jsonfile.추가2 < 10) {
} else {
south1stStore[0].style.display = "block";
subQuestNotEnd[0].style.display = "block";
RPGinCity_HandleStore(jsonfile, 0);
}
} else {
south1stStore[1].style.display = "block";
RPGinCity_HandleStore(jsonfile, 1);
}
}
}
// 자동 세이브 처리 - 가장 마지막에 와야 하는 것
//시청 안의 산토끼 몰매 맞고 가나요~
var saveGameHandle = document.getElementById("saveGame");
let cityOffice = document.getElementsByClassName("cityOffice");
if (saveGameHandle !== undefined && saveGameHandle !== null) {
if (cityOffice !== undefined && cityOffice !== null && cityOffice.length > 0) {
console.log("Saving...");
if (jsonfile.추가2 < 70) {
RPGinCity_SaveHandle(saveGameHandle);
cityOffice[0].style.display = "block";
} else {
cityOffice[1].style.display = "block";
}
}
}
}
let cityOfficeInternal = document.getElementsByClassName("cityOfficeInternal");
if (cityOfficeInternal !== undefined && cityOfficeInternal !== null && cityOfficeInternal.length > 0) {
if (jsonfile.추가2 >= 65) {
// ----------------------------------------------------Main------------------------------------------------------------
cityOfficeInternal[0].style.display = "block";
} else {
RPGinCity_Title();
cityOfficeInternal[1].style.display = "block";
}
if (currentpage === "사용자:"+usernameStr+"/RPG_in_City.json"){
RPGinCity_GoToCheckpoint();
}
}
let cityOffice3F = document.getElementsByClassName("cityOffice3F");
else if (currentpage.substring(0,11) === "RPG_in_City") { // in game but not in title screen
if (cityOffice3F !== undefined && cityOffice3F !== null && cityOffice3F.length > 0) {
var api = new mw.Api();
if (jsonfile.추가2 >= 65) {
console.log("fetching player info...");
cityOffice3F[0].style.display = "block";
fetch("https://liberty.banipest.com/index.php?title="+"사용자:"+usernameStr+"/RPG_in_City.json"+"&action=raw")
} else {
.then(function(response) {
cityOffice3F[1].style.display = "block";
if (!response.ok) {
}
        // make the promise be rejected if we didn't get a 2xx response
}
        throw new Error("Not 2xx response", {cause: response});
let mayorRoom = document.getElementsByClassName("mayorRoom");
    }
if (mayorRoom !== undefined && mayorRoom !== null && mayorRoom.length > 0) {
return response.json();
if (jsonfile.추가2 >= 70) {
})
mayorRoom[0].style.display = "block";
.then(function(response) {
} else {
var parsedata = response;
mayorRoom[1].style.display = "block";
RPGinCity_Callback_fetchUserInformation(parsedata);
}
}
}
)
// 서브 퀘스트 관련
.catch(function(e){
let subQuestContents = document.getElementsByClassName("SubQuestContent");
console.log(e);
if (subQuestContents !== undefined && subQuestContents !== null && subQuestContents.length > 0) {
document.getElementById("RPGinCityLoad").style.display = "none";
let parentNode = subQuestContents[0].parentElement;
});
subQuestContents[jsonfile.추가1].style.display = "block";
let targetContent = subQuestContents[jsonfile.추가1];
for (let i of subQuestContents){
parentNode.removeChild( i );
}
parentNode.appendChild(targetContent);
}
}
// 자동 세이브 처리 - 가장 마지막에 와야 하는 것
let saveGameHandle = document.getElementById("saveGame");
if (saveGameHandle !== undefined && saveGameHandle !== null) {
console.log("Saving...");
RPGinCity_SaveHandle(saveGameHandle);
}
}


// ----------------------------------------------------Main------------------------------------------------------------
RPGinCity_Title();
if (currentpage === "사용자:"+usernameStr+"/RPG_in_City.json"){
RPGinCity_GoToCheckpoint();
}
else if (currentpage.substring(0,11) === "RPG_in_City") { // in game but not in title screen
console.log("fetching player info...");
fetch("https://libertygame.miraheze.org/w/index.php?title="+"사용자:"+usernameStr+"/RPG_in_City.json"+"&action=raw")
.then(response => response.json())
.then(response => RPGinCity_Callback_fetchUserInformation(response));
}
}
$(RPGinCity);

2023년 7월 9일 (일) 00:46 기준 최신판

function RPGinCity(){
	var usernameStr = mw.user.getName();
	var currentpage = mw.config.get("wgPageName");
	var pagenode = currentpage.split('/');
	console.log("사용자:"+ usernameStr + "/RPG_in_City.json");
	if (pagenode[0] !== "RPG_in_City"){
		if (currentpage !== "사용자:"+ usernameStr + "/RPG_in_City.json") {
			console.log("Current page is "+ currentpage +", not playing RPG in City");
			return;
		}
	}
	var fullbasepagename = "";
	for (var node = 0 ; node < pagenode.length - 2; node++){
		fullbasepagename = fullbasepagename + pagenode[node] + "/";
	}
	fullbasepagename = fullbasepagename + pagenode[pagenode.length - 2];
	console.log(fullbasepagename);
	
	
	function RPGinCity_Title() {
		var startbuttondiv = document.getElementById("RPGinCityStart");
		var loadbuttondiv =  document.getElementById("RPGinCityLoad");
		if (startbuttondiv !== null && loadbuttondiv !== null){
			if (usernameStr === null) {
				startbuttondiv.innerHTML = "<p>로그인이 필요합니다</p>";
			} else {
				var UserDBTitle = new mw.Title("사용자:"+usernameStr+"/RPG in City.json");
				startbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText(),{action: 'edit', preload : '틀:RPG_in_City_DB_양식', summary:'생성'})+ "\">시작하기</a></big></p>";
				loadbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText())+ "\">계속하기</a></big></p>";
	
			}
		}
	}
	
	function RPGinCity_GoToCheckpoint () {
		var JSONDatalist = document.getElementsByClassName("mw-json-value");
		if (currentpage === ("사용자:"+usernameStr+"/RPG_in_City.json") && JSONDatalist.length !== 0) {
			var MWContent = document.getElementById("mw-content-text"); 
			var GotoLink= document.createElement("a");
			GotoLink.href = mw.util.getUrl((JSONDatalist[0].innerText.substring(1, JSONDatalist[0].innerText.length-1)));
			console.log(GotoLink.href);
			GotoLink.innerText = "게임 계속하기";
			MWContent.appendChild(GotoLink);
		}
	}
	
	function RPGinCity_pushFightInfo(targetUri, Mhp, Ehp, Jam, PJam, BanBomb, Etype, Elevel, Turn) {
		targetUri.extend({mhp:Mhp});
		targetUri.extend({ehp:Ehp});
		targetUri.extend({j:Jam});
		targetUri.extend({bj:PJam});
		targetUri.extend({bb:BanBomb});
		targetUri.extend({etype:Etype});
		targetUri.extend({elevel:Elevel});
		targetUri.extend({turn:Turn});
		return targetUri;
	}
	
	function RPGinCity_HandleBattle(jsonfile) {
		var Battlelink = new mw.Uri(window.location.href);
		console.log("building battle phase...");
		var queryparams = Battlelink.query;
		// 이제 필요한 값을 구해 화면에 표시한다.
		// 플레이어 체력부터...
		var mhp = 0;
		var playerhealth = document.getElementById("playerhealth");
		if (isNaN(queryparams.mhp)) {
			mhp = jsonfile.체력;
		} else {
			mhp = queryparams.mhp; // mhp는 이전 문서의 값을 받는다.
		}
		playerhealth.innerText = mhp;
		//적의 레벨
		var enemylevel = document.getElementById("enemylevel");
		enemylevel.innerText = queryparams.elevel; // elevel는 항상 undefined이 아니다.
		//적의 체력
		var enemyhealth = document.getElementById("enemyhealth");
		enemyhealth.innerText = queryparams.ehp; // ep는 항상 undefined이 아니다.
		//공격 페이즈
		var nextPhaseUri = new mw.Uri("https://liberty.banipest.com/index.php?title="+currentpage);
		var attackEnemy = document.getElementById("attackEnemy");
		var attackPower = Math.round(Math.random() * jsonfile.레벨*3) + jsonfile.무기;
		var attackEnemyUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, (queryparams.ehp - attackPower) >= 0?queryparams.ehp - attackPower : 0, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
		if (attackEnemy !== undefined && attackEnemy !== null)attackEnemy.innerHTML="<a href=\"" + attackEnemyUri.toString() + "\">그냥 공격!</a>";
		var useJam = document.getElementById("useJam");
		var useJamUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), jsonfile.체력, queryparams.ehp, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
		if (useJam !== undefined && useJam !== null)useJam.innerHTML="<a href=\"" + useJamUri.toString() + "\">잼으로 회복!</a>";
		var usePJ = document.getElementById("usePJ");
		var usePJUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, queryparams.ehp > 20 ? queryparams.ehp - 20 : 0, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
		if (usePJ !== undefined && usePJ !== null)usePJ.innerHTML="<a href=\"" + usePJUri.toString() + "\">배쨈 열기!</a>";
		var useBanbomb = document.getElementById("useBanbomb");
		var useBanbombUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp, queryparams.ehp/2, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 2);
		if (useBanbomb !== undefined && useBanbomb !== null)useBanbomb.innerHTML="<a href=\"" + useBanbombUri.toString() + "\">차단폭탄!</a>";
		//방어 페이즈
		var Blocking = document.getElementById("Block");
		var BlockingUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp- Math.round(Math.random() * queryparams.elevel * 0.75), queryparams.ehp , queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 1);
		if (Blocking !== undefined && Blocking !== null)Blocking.innerHTML="<a href=\"" + BlockingUri.toString() + "\">방어</a>";
		var FailRunning = document.getElementById("FailRunning");
		var FailRunningUri = RPGinCity_pushFightInfo(nextPhaseUri.clone(), mhp - Math.round(Math.random() * queryparams.elevel), queryparams.ehp, queryparams.j, queryparams.bj, queryparams.bb, queryparams.etype, queryparams.elevel, 1);
		if (FailRunning !== undefined && FailRunning !== null)FailRunning.innerHTML="<a href=\"" + FailRunningUri.toString() + "\">도망치자!</a>";
		var RunFromEnemy = document.getElementById("RunFromEnemy");
		var MustKill = document.getElementById("mustKill");
		if (RunFromEnemy !== undefined && RunFromEnemy !== null && (MustKill === undefined || MustKill === null))RunFromEnemy.style.visibility = "visible";
	}
	
	function RPGinCity_SaveHandle(saveGameHandle) {
		var api = new mw.Api();
		var Templink = new mw.Uri(window.location.href);
		var queryparams = Templink.query;
		switch (saveGameHandle.innerText){
			case "서브퀘스트완료":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					jsondata.추가1 = 0;
					jsondata.최근페이지 = fullbasepagename;
					return {text: JSON.stringify(jsondata), summary: "서브퀘스트완료"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			case "서브퀘스트수행":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					var questID = document.getElementById("questID");
					if (questID !== undefined && questID !== null){
						jsondata.추가1 = parseInt(questID.innerText);
						jsondata.최근페이지 = fullbasepagename;
					}
					return {text: JSON.stringify(jsondata), summary: "서브퀘스트수행"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			case "메인퀘스트수행":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					var mainQuestPoint = document.getElementById("mainQuestPoint");
					if (mainQuestPoint !== undefined && mainQuestPoint !== null) jsondata.최근페이지 = mainQuestPoint.innerText;
					var questID = document.getElementById("questID");
					if (questID !== undefined && questID !== null)jsondata.추가2 = parseInt(questID.innerText);
					return {text: JSON.stringify(jsondata), summary: "메인퀘스트수행"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			case "동부요금지불":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					jsondata. -= 500*1;
					jsondata.추가2 = 5*1; // force to parse it a number
					jsondata.최근페이지 = "RPG in City/만남의 광장";
					return {text: JSON.stringify(jsondata), summary: "동부요금지불"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			case "전투승리":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					jsondata.체력 = parseInt(queryparams.mhp);
					jsondata.경험치 += queryparams.elevel*4;
					jsondata. += queryparams.elevel*5;
					jsondata.최근페이지 = currentpage.substring(0, currentpage.length-3);
					return {text: JSON.stringify(jsondata), summary: "전투승리"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			case "레벨업":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					jsondata.레벨 += (jsondata.경험치 - jsondata.경험치 % 128)/128;
					jsondata.경험치 = jsondata.경험치 % 128;
					return {text: JSON.stringify(jsondata), summary: "레벨업"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			case "회복":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					jsondata.체력 = jsondata.레벨 * 16;
					return {text: JSON.stringify(jsondata), summary: "회복"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			case "결제":
				new mw.Api().edit("사용자:"+usernameStr+"/RPG_in_City.json", function (revision) {
					var jsondata = JSON.parse(revision.content);
					jsondata. += queryparams.j*1;
					jsondata.배쨈 += queryparams.bj*1;
					jsondata.차단폭탄 += queryparams.bb*1;
					jsondata.무기 += queryparams.weapon*1;
					jsondata. -= 50* queryparams.j + 75*queryparams.bj + 150*queryparams.bb + 1000 * queryparams.weapon;
					jsondata.최근페이지 = currentpage.substring(0, currentpage.length-3);
					return {text: JSON.stringify(jsondata), summary: "결제"};
				}
				).then(function () {
				    alert( 'Saved!' );
				    saveGameHandle.innerHTML="<a href=\"https://liberty.banipest.com/index.php?title="+ "사용자:"+usernameStr+"/RPG_in_City.json\">저장 확인하기</a>";
				});
				break;
			default:
				    alert( 'No proper parameters' );
				break;
		}
	}
	
	function RPGinCity_HandleStore(jsondata, storeNumber) {
		var i = storeNumber;
		var Jam = document.getElementsByClassName("JamAmount")[i];
		if (Jam !== undefined && Jam !== null && Jam.innerText === "") Jam.innerText = "0";
		var PearJam = document.getElementsByClassName("PearJamAmount")[i];
		if (PearJam !== undefined && PearJam !== null && PearJam.innerText === "") PearJam.innerText = "0";
		var BB = document.getElementsByClassName("BanBombAmount")[i];
		if (BB !== undefined && BB !== null && BB.innerText === "") BB.innerText = "0";
		var WeaponLevelUp = document.getElementsByClassName("WeaponLevelUp")[i];
		if (WeaponLevelUp !== undefined && WeaponLevelUp !== null && WeaponLevelUp.innerText === "") WeaponLevelUp.innerText = "0";
		var BuyButton = document.getElementsByClassName("BuyButton")[i];
		if (BuyButton !== undefined && BuyButton !== null) {
			if (50 * parseInt(Jam.innerText) + 75 * parseInt(PearJam.innerText) + 150* parseInt(BB.innerText) + 1000*parseInt(WeaponLevelUp.innerText) > jsondata.) {
				BuyButton.innerText = "돈이 부족하다. 나가서 돈을 구해오자.";
			}
			BuyButton.style.visibility = "visible";
		}
	}
	
	function RPGinCity_Callback_fetchUserInformation(jsonfile) {
		// 정보 틀 관련
		var playerinfo = document.getElementsByClassName("Playerinfo");
		var LevelUpButton = document.getElementById("LevelUp");
		if ( playerinfo !== undefined && playerinfo !== null && playerinfo.length > 0)  {
			playerinfo[0].innerText = jsonfile['레벨'];
			playerinfo[1].innerText = jsonfile['체력'];
			playerinfo[2].innerText = jsonfile['경험치'];
			playerinfo[3].innerText = jsonfile['잼'];
			playerinfo[4].innerText = jsonfile['배쨈'];
			playerinfo[5].innerText = jsonfile['차단폭탄'];
			playerinfo[6].innerText = jsonfile['돈'];
			playerinfo[7].innerText = jsonfile['무기'];
			if (LevelUpButton !== undefined && LevelUpButton !== null && jsonfile.경험치 > 128 && jsonfile.레벨 + jsonfile.경험치 /128 <= 50) {
				LevelUpButton.innerHTML = "<a href= \"https://liberty.banipest.com/index.php/RPG_in_City/레벨_업\">레벨 업!</a>";
			}
		}
		// RPG in City/집 쉬기 기능
		var RestingInHouse = document.getElementById("House");
		if (RestingInHouse !== undefined && RestingInHouse != null) {
			if (jsonfile.체력 < jsonfile.레벨 * 16){
				RestingInHouse.innerHTML = "너는 한숨 자고 개운한 마음으로 이곳을 나가려고 한다.\n<a href=\"https://liberty.banipest.com/index.php/RPG_in_City/"+currentpage+"/회복\">쉬기</a>";
			}
			RestingInHouse.style.visibility = "visible";
		}
		// RPG in City 전투 관련 스크립트
		var inBattle = document.getElementById("Fight");
		if (inBattle !== undefined && inBattle !== null){ 
			RPGinCity_HandleBattle(jsonfile);
		} // 전투 틀 처리 완료
		// 일반적인 상점(문서 내에 단 한 개 존재) 처리
		var storeHandle = document.getElementById("RiCStore");
		if (storeHandle !== undefined && storeHandle !== null){
			RPGinCity_HandleStore(jsonfile, 0);
		}
		//동부2구역구 - 중부구역구 이동 가능 여부 처리
		var DowntownRoadOpen = document.getElementById("DowntownRoad");
		if (DowntownRoadOpen !== undefined && DowntownRoadOpen !== null) {
			if (jsonfile.추가2 < 60) {
				DowntownRoadOpen.innerText = "이런!!! 다운타운 로드는 반달로 인해 막혀있다.";
			}
			DowntownRoadOpen.style.visibility = "visible";
		}
		//남부 1구역구 메인퀘스트
		var south1st = document.getElementById("south1st");
		if (south1st !== undefined && south1st !== null) {
			var displaypart;
			if (jsonfile.추가2 < 10){
				displaypart = document.getElementById("beforeBossfight");
				displaypart.style.display = "block";
			} else {
				displaypart = document.getElementById("afterBossfight");
				displaypart.style.display = "block";
			}
		}
		//중부구역구
		var toWest = document.getElementById("toWest");
		if (toWest !== undefined && toWest !== null) {
			if (jsonfile.추가2 < 25) {
				toWest.innerText = "서부 구역구 방향으로 가기 - <중부 구역구가 파괴된 시점에서 서부 구역구를 분리하는 장벽은 강력한 반달러들로 인해 봉쇄 상태를 유지하고 있다>";
			}
			toWest.style.visibility = "visible";
		}
		var toCentralOffice = document.getElementById("toCentralOffice");
		if (toCentralOffice !== undefined && toCentralOffice !== null) {
			if (jsonfile.추가2 < 40) {
				toCentralOffice.innerText = "시청으로 들어가기 - < 시청에 들어갈 방법을 찾아야 한다 >";
			}
			toCentralOffice.style.visibility = "visible";
		}
		var peacefulCentral = document.getElementById("peacefulCentral");
		var dangerousCentral = document.getElementById("dangerousCentral");
		if (peacefulCentral !== undefined && peacefulCentral !== null && dangerousCentral !== undefined && dangerousCentral !== null) {
			if (jsonfile.추가2 >= 70) {
				peacefulCentral.style.visibility = "visible";
			} else {
				dangerousCentral.style.visibility = "visible";
			}
		}
		// 중부 구역구 대피소 퀘스트
		var rescuePeregirl = document.getElementsByClassName("rescuePeregirl");
		if (rescuePeregirl !== undefined && rescuePeregirl !== null && rescuePeregirl.length > 0) {
			if (jsonfile.추가2 < 15) {
				rescuePeregirl[1].remove();
				rescuePeregirl[0].style.display = "block";
			} else if (jsonfile.추가2 === 20) {
				rescuePeregirl[0].remove();
				rescuePeregirl[0].style.display = "block";
			} else {
				rescuePeregirl[0].remove();
				rescuePeregirl[0].remove();
				rescuePeregirl[0].style.display = "block";
			}
		}
		var meetPeregirl = document.getElementsByClassName("meetPeregirl");
		if (meetPeregirl !== undefined && meetPeregirl !== null && meetPeregirl.length > 0) {
			if (jsonfile.추가2 < 20) {
				meetPeregirl[0].style.display = "block";
			} else {
				meetPeregirl[0].remove();
				meetPeregirl[0].style.display = "block";
			}
		}
		//남부 1구역구 상점, 문서 구조상 좀 구현이 복잡하여 분리한다.
		var south1stStore = document.getElementsByClassName("south1stStore");
		if (south1stStore !== undefined && south1stStore !== null && south1stStore.length > 0) {
			if (jsonfile.추가2 < 10) {
				south1stStore[0].style.display = "block";
				RPGinCity_HandleStore(jsonfile, 0);
			} else {
				south1stStore[1].style.display = "block";
				RPGinCity_HandleStore(jsonfile, 1);
			}
		}
		//시청 안의 산토끼 몰매 맞고 가나요~
		var cityOffice = document.getElementsByClassName("cityOffice");
		if (cityOffice !== undefined && cityOffice !== null && cityOffice.length > 0) {
			if (jsonfile.추가2 < 70) {
				cityOffice[0].style.display = "block";
			} else {
				cityOffice[1].style.display = "block";
			}
		}
		var cityOfficeInternal = document.getElementsByClassName("cityOfficeInternal");
		if (cityOfficeInternal !== undefined && cityOfficeInternal !== null && cityOfficeInternal.length > 0) {
			if (jsonfile.추가2 >= 65) {
				cityOfficeInternal[0].style.display = "block";
			} else {
				cityOfficeInternal[1].style.display = "block";
			}
		}
		var cityOffice3F = document.getElementsByClassName("cityOffice3F");
		if (cityOffice3F !== undefined && cityOffice3F !== null && cityOffice3F.length > 0) {
			if (jsonfile.추가2 >= 65) {
				cityOffice3F[0].style.display = "block";
			} else {
				cityOffice3F[1].style.display = "block";
			}
		}
		var mayorRoom = document.getElementsByClassName("mayorRoom");
		if (mayorRoom !== undefined && mayorRoom !== null && mayorRoom.length > 0) {
			if (jsonfile.추가2 >= 70) {
				mayorRoom[0].style.display = "block";
			} else {
				mayorRoom[1].style.display = "block";
			}
		}
		// 서브 퀘스트 관련
		var subQuestContent = document.getElementById("SubQuestContent");
		var parentNode;
		if (subQuestContent !== undefined && subQuestContent !== null){
			parentNode = subQuestContent.parentElement;
		}
		if (parentNode !== undefined && parentNode !== null && subQuestContent !== undefined && subQuestContent !== null) {
			if (jsonfile.추가1 !== 0) {
				parentNode.removeChild( subQuestContent );
			} else {
				subQuestContent.style.display = "block";
			}
		}
		var subQuestEnd = document.getElementById("SubQuestEnd");
		if (parentNode !== undefined && parentNode !== null &&subQuestEnd !== undefined && subQuestEnd !== null) {
			if (jsonfile.추가1 !== 1) {
				parentNode.removeChild( subQuestEnd );
			} else {
				subQuestEnd.style.display = "block";
			}
		}
		var subQuestNotEnd = document.getElementsByClassName("SubQuestNotEnd");
		if (parentNode !== undefined && parentNode !== null && subQuestNotEnd !== undefined && subQuestNotEnd !== null) {
			if (jsonfile.추가1 <2) {
				parentNode.removeChild( subQuestNotEnd[0] );
			} else {
				subQuestNotEnd[0].style.display = "block";
			}
		}
		// 자동 세이브 처리 - 가장 마지막에 와야 하는 것
		var saveGameHandle = document.getElementById("saveGame");
		if (saveGameHandle !== undefined && saveGameHandle !== null) {
			console.log("Saving...");
			RPGinCity_SaveHandle(saveGameHandle);
		}
	}
	
	
	// ----------------------------------------------------Main------------------------------------------------------------
	
	RPGinCity_Title();
	
	if (currentpage === "사용자:"+usernameStr+"/RPG_in_City.json"){
		RPGinCity_GoToCheckpoint();
	}
	else if (currentpage.substring(0,11) === "RPG_in_City") { // in game but not in title screen
		var api = new mw.Api();
		console.log("fetching player info...");
		fetch("https://liberty.banipest.com/index.php?title="+"사용자:"+usernameStr+"/RPG_in_City.json"+"&action=raw")
			.then(function(response) {
				if (!response.ok) {
			        // make the promise be rejected if we didn't get a 2xx response
			        throw new Error("Not 2xx response", {cause: response});
			    }
				return response.json();
			})
			.then(function(response) {
				var parsedata = response;
				RPGinCity_Callback_fetchUserInformation(parsedata);
			}
			)
			.catch(function(e){
				console.log(e);
				document.getElementById("RPGinCityLoad").style.display = "none";
			});
	}

}
$(RPGinCity);