사용자:Senouis/RPGinCity.js: 두 판 사이의 차이
imported>Senouis (통째로 링크 갈아치우기) |
imported>Senouis 잔글편집 요약 없음 |
||
54번째 줄: | 54번째 줄: | ||
if (GetReadyToBattle !== undefined) { | if (GetReadyToBattle !== undefined) { | ||
console.log("building battle phase..."); | console.log("building battle phase..."); | ||
GetReadyToBattle.innerHTML = "[{{fullurl: {{urlencode:{{{3| | GetReadyToBattle.innerHTML = "[{{fullurl: {{urlencode:{{{3|"+currentpage+"/전투}}}}}|etype={{{5|0}}}&ehp={{{1|1}}}&elevel={{{2|2}}}&turn=2&mhp="+jsonfile.체력+"&j="+jsonfile.잼+"&bj="+jsonfile.배쨈+"&bb="+jsonfile.차단폭탄 + "}} <span style=\"font-weight:bold; color:{{{색|blue}}}\"><big>→</big></span>]"; | ||
} | } |
2020년 12월 2일 (수) 14:08 판
let usernameStr = mw.user.getName();
let currentpage = mw.config.get("wgPageName");
console.log(currentpage);
function RPGinCity_Title() {
let startbuttondiv = document.getElementById("RPGinCityStart");
if (startbuttondiv !== null){
if (usernameStr === null) {
startbuttondiv.innerHTML = "<p>로그인이 필요합니다</p>";
} else {
let UserDBTitle = new mw.Title("사용자:"+usernameStr+"/RPG in City.json", 2);
if (UserDBTitle.exists === true){
startbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText())+ "\">계속하기</a></big></p>";
} else {
startbuttondiv.innerHTML = "<p><big><a href=\""+mw.util.getUrl(UserDBTitle.toText(),{action: 'edit', preload : '틀:RPG_in_City_DB_양식', summary:'생성'})+ "\">새 데이터 만들기</a></big></p>";
}
}
}
}
function RPGinCity_GoToCheckpoint () {
let JSONDatalist = document.getElementsByClassName("mw-json-value");
if (currentpage === ("사용자:"+usernameStr+"/RPG_in_City.json") && JSONDatalist.length !== 0) {
let MWContent = document.getElementById("mw-content-text");
let 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_Callback_fetchUserInformation(jsonfile) {
let playerinfo = document.getElementsByClassName("Playerinfo");
let LevelUpButton = document.getElementById("LevelUp");
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 (jsonfile.경험치 > 128 && jsonfile.레벨 + jsonfile.경험치 /128 <= 50) {
LevelUpButton.innerHTML = "<a href= \"https://libertygame.miraheze.org/wiki/RPG_in_City/레벨_업\">레벨 업!</a>";
}
// RPG in City/집 쉬기 기능
let RestingInHouse = document.getElementById("House");
if (RestingInHouse !== undefined && jsonfile.체력 < jsonfile.레벨 * 16){
RestingInHouse.innerText = "너는 한숨 자고 개운한 마음으로 집을 나가려고 한다.\n[[/회복|쉬기]]";
}
let GetReadyToBattle = document.getElementById("BattleLink");
if (GetReadyToBattle !== undefined) {
console.log("building battle phase...");
GetReadyToBattle.innerHTML = "[{{fullurl: {{urlencode:{{{3|"+currentpage+"/전투}}}}}|etype={{{5|0}}}&ehp={{{1|1}}}&elevel={{{2|2}}}&turn=2&mhp="+jsonfile.체력+"&j="+jsonfile.잼+"&bj="+jsonfile.배쨈+"&bb="+jsonfile.차단폭탄 + "}} <span style=\"font-weight:bold; color:{{{색|blue}}}\"><big>→</big></span>]";
}
}
// ----------------------------------------------------Main------------------------------------------------------------
if (currentpage === "RPG in City") {
RPGinCity_Title();
}
else 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));
}