백괴게임>Bd3076 |
백괴게임>Bd3076 |
1번째 줄: |
1번째 줄: |
| var keyPress = new Array(128);
| |
|
| |
|
| document.onkeydown = function(e){
| |
| e = e || window.event;
| |
| keyPress[e.keyCode] = 1;
| |
| }
| |
|
| |
| document.onkeyup = function(e){
| |
| e = e || window.event;
| |
| keyPress[e.keyCode] = 0;
| |
| }
| |
|
| |
| var cvs = document.getElementById("cvs");
| |
| cvs.innerHTML = ('<canvas id="canvas" width="480" height="480"></canvas>')
| |
| var canvas = document.getElementById('canvas');
| |
| var ctx = canvas.getContext('2d');
| |
|
| |
| ctx.fillStyle = "black";
| |
| ctx.fillRect(0, 0, 500, 500);
| |
|
| |
| var stopWatchH = 0;
| |
| var stopWatchM = 0;
| |
| var stopWatchS = 0;
| |
| var stopWatchSS = 0;
| |
|
| |
| var addStopwatch = function(){
| |
| stopWatchSS++;
| |
| if(stopWatchSS == 10){
| |
| stopWatchS++;
| |
| stopWatchSS = 0;
| |
| if(stopWatchS == 60){
| |
| stopWatchM++;
| |
| stopWatchS = 0;
| |
| if(stopWatchM == 60){
| |
| stopWatchH++;
| |
| stopWatchM = 0;
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
| var setStopwatch = function(){
| |
| stopwatchH = 0;
| |
| stopwatchM = 0;
| |
| stopwatchS = 0;
| |
| stopwatchSS = 0;
| |
| setInterval(addStopwatch, 100);
| |
| }
| |
|
| |
| var setCookie = function(name, value) {
| |
| var date = new Date();
| |
| date.setTime(date.getTime() + 12345678987654321);
| |
| document.cookie = name + '=' + value + ';expires=' + date.toUTCString() + ';path=/';
| |
| };
| |
|
| |
| var getCookie = function(name) {
| |
| var value = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
| |
| return value? value[2] : null;
| |
| };
| |
|
| |
| // road variable
| |
| // 2^0: right (+x)
| |
| // 2^1: down (-y)
| |
| // 2^2: left (-x)
| |
| // 2^3: up (+y)
| |
|
| |
| var levelCount = 1;
| |
|
| |
| var levelData = new Array(levelCount);
| |
| levelData[0] = {
| |
| x: 4,
| |
| y: 4,
| |
| startX: 0,
| |
| startY: 0,
| |
| finishX: 1,
| |
| finishY: 0,
| |
| road: [
| |
| [8, 3, 5, 12],
| |
| [11, 4, 1, 14],
| |
| [10, 8, 1, 6],
| |
| [2, 3, 5, 4]
| |
| ],
| |
| switch_road: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [[{dir:1, num:2}], [{dir:4, num:2}],0,0]
| |
| ],
| |
| switch_num: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [2, 0, 0, 0],
| |
| [0, 0, 0, 0]
| |
| ],
| |
| lever_road: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, [{dir:8, num:2}], 0],
| |
| [0, 0, [{dir:2, num:2}], 0]
| |
| ],
| |
| lever: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 2]
| |
| ],
| |
| lever_point: [
| |
| 0, 0, 3
| |
| ],
| |
| switch_open: [
| |
| 0, 0, 0
| |
| ],
| |
| lever_open: [
| |
| 0, 0, 0
| |
| ]
| |
| };
| |
|
| |
| var levelClear = function(level){
| |
| ctx.fillStyle = "white";
| |
| ctx.fillText("레벨 " + level + " 클리어!", 240, 200);
| |
| ctx.fillText("걸린 시간: " + stopWatchH + "시간 " + stopWatchM + "분 " + stopWatchS + "." + stopWatchSS + "초", 240, 240);
| |
| ctx.fillText("다음 레벨로 넘어가시려면 [Space]를 누르세요.", 240, 280);
| |
| setCookie("level", level+1);
| |
| waitToPlayLevel(level+1);
| |
| }
| |
|
| |
| var displayRoom = function(level, x, y){
| |
| ctx.fillStyle = "black";
| |
| ctx.fillRect(0, 0, 500, 500);
| |
|
| |
| console.log("x: " + x + ", y: " + y + ", road: " + levelData[level].road[y][x]);
| |
|
| |
| if(x == levelData[level].finishX && y == levelData[level].finishY){
| |
| levelClear(level);
| |
| return;
| |
| }
| |
|
| |
| var road = levelData[level].road[y][x];
| |
| var switch_road = levelData[level].switch_road[y][x];
| |
| var switch_num = levelData[level].switch_num[y][x];
| |
| var lever_road = levelData[level].lever_road[y][x];
| |
| var lever = levelData[level].lever[y][x];
| |
|
| |
| var roadRight = (road & 1);
| |
| var roadDown = (road & 2) / 2;
| |
| var roadLeft = (road & 4) / 4;
| |
| var roadUp = (road & 8) / 8;
| |
|
| |
| for(var i=0; i<switch_road.length; i++){
| |
| var t_sdir = switch_road[i].dir;
| |
| if(t_sdir & 1) roadRight = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| if(t_sdir & 2) roadDown = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| if(t_sdir & 4) roadLeft = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| if(t_sdir & 8) roadUp = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| }
| |
|
| |
| for(var i=0; i<lever_road.length; i++){
| |
| var t_ldir = lever_road[i].dir;
| |
| if(t_ldir & 1) roadRight = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| if(t_ldir & 2) roadDown = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| if(t_ldir & 4) roadLeft = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| if(t_ldir & 8) roadUp = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| }
| |
|
| |
| ctx.fillStyle = "white";
| |
| ctx.fillRect(120, 120, 240, 240);
| |
| if(roadRight){
| |
| ctx.fillStyle = roadRight == 1 ? "white" : roadRight == 2 ? "blue" : "purple";
| |
| ctx.fillRect(360, 180, 120, 120);
| |
| }
| |
| if(roadDown){
| |
| ctx.fillStyle = roadDown == 1 ? "white" : roadDown == 2 ? "blue" : "purple";
| |
| ctx.fillRect(180, 360, 120, 120);
| |
| }
| |
| if(roadLeft){
| |
| ctx.fillStyle = roadLeft == 1 ? "white" : roadLeft == 2 ? "blue" : "purple";
| |
| ctx.fillRect(0, 180, 120, 120);
| |
| }
| |
| if(roadUp){
| |
| ctx.fillStyle = roadUp == 1 ? "white" : roadUp == 2 ? "blue" : "purple";
| |
| ctx.fillRect(180, 0, 120, 120);
| |
| }
| |
|
| |
| if(roadRight == 1) road |= 1;
| |
| if(roadDown == 1) road |= 2;
| |
| if(roadLeft == 1) road |= 4;
| |
| if(roadUp == 1) road |= 8;
| |
|
| |
| setTimeout(waitForKey, 200, level, x, y, road);
| |
|
| |
| if(levelData[level].switch_num[y][x]){
| |
| ctx.fillStyle = "blue";
| |
| if(levelData[level].switch_open[levelData[level].switch_num[y][x]]){
| |
| ctx.fillRect(130, 130, 50, 220);
| |
| }
| |
| else{
| |
| ctx.fillRect(140, 140, 30, 200);
| |
| }
| |
| }
| |
| if(levelData[level].lever[y][x]){
| |
| ctx.fillStyle = "purple";
| |
| if(levelData[level].lever_open[levelData[level].lever[y][x]]){
| |
| ctx.fillRect(300, 130, 50, 220);
| |
| }
| |
| else{
| |
| ctx.fillRect(310, 140, 30, 200);
| |
| }
| |
| }
| |
| }
| |
|
| |
| var counter = 0;
| |
|
| |
| var waitForKey = function(level, x, y, road){
| |
| counter++;
| |
| var canPressSpace;
| |
| if(levelData[level].switch_num[y][x] == 0 && levelData[level].lever[y][x] == 0){
| |
| canPressSpace = 0;
| |
| }
| |
| else{
| |
| canPressSpace = 1;
| |
| }
| |
|
| |
| if((!keyPress[32] || !canPressSpace) &&
| |
| (!keyPress[37] || x==0 || !(road&4)) &&
| |
| (!keyPress[38] || y==levelData[level].y-1 || !(road&8)) &&
| |
| (!keyPress[39] || x==levelData[level].x-1 || !(road&1)) &&
| |
| (!keyPress[40] || y==0 || !(road&2))){
| |
| setTimeout(waitForKey, 30, level, x, y, road);
| |
| counter--;
| |
| return;
| |
| }
| |
| else{
| |
| if(keyPress[32] && canPressSpace){
| |
| console.log("pressed space");
| |
| keyPress[32] = 0;
| |
| if(levelData[level].switch_num[y][x] > 0){
| |
| levelData[level].switch_open[levelData[level].switch_num[y][x]] = 1 - levelData[level].switch_open[levelData[level].switch_num[y][x]];
| |
| displayRoom(level, x, y);
| |
| return;
| |
| }
| |
| if(levelData[level].lever[y][x] > 0){
| |
| levelData[level].lever_open[levelData[level].lever[y][x]] = levelData[level].lever_point[levelData[level].lever[y][x]];
| |
| displayRoom(level, x, y);
| |
| return;
| |
| }
| |
| counter--;
| |
| return;
| |
| }
| |
| else{
| |
| for(var i=0; i<levelData[level].lever_open.length; i++){
| |
| levelData[level].lever_open[i]--;
| |
| if(levelData[level].lever_open[i] < 0) levelData[level].lever_open[i] = 0;
| |
| }
| |
| if(keyPress[37] && x!=0 && road&4){
| |
| console.log("pressed left");
| |
| displayRoom(level, x-1, y);
| |
| keyPress[37] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| else if(keyPress[38] && y!=levelData[level].y-1 && road&8){
| |
| console.log("pressed up");
| |
| displayRoom(level, x, y+1);
| |
| keyPress[38] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| else if(keyPress[39] && x!=levelData[level].x-1 && road&1){
| |
| console.log("pressed down");
| |
| displayRoom(level, x+1, y);
| |
| keyPress[39] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| else if(keyPress[40] && y!=0 && road&2){
| |
| console.log("pressed right");
| |
| displayRoom(level, x, y-1);
| |
| keyPress[40] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
| var playLevel = function(level){
| |
| var thisLevelData = levelData[level];
| |
| setStopwatch();
| |
| addStopwatch();
| |
| console.log(thisLevelData);
| |
| displayRoom(level, thisLevelData.startX, thisLevelData.startY);
| |
| }
| |
|
| |
| var main = function(){
| |
| ctx.font = "15px Dotum";
| |
| ctx.textAlign = "center";
| |
| ctx.fillStyle = "white";
| |
| var level = getCookie("level");
| |
| if(level != null){
| |
| ctx.fillText("저장된 파일이 있습니다. 이어 플레이하시겠습니까?", 240, 200);
| |
| ctx.fillText("예: [Space], 아니오: [↑]", 240, 240);
| |
| waitToPlayLevel(level, 1);
| |
| }
| |
| else{
| |
| level = 0;
| |
| ctx.fillText("스위치 미로", 240, 120);
| |
| ctx.fillText("Bd3076", 240, 150);
| |
| ctx.fillText("움직이려면 [방향키]를 누르세요.", 240, 240);
| |
| ctx.fillText("스위치나 레버를 누르려면 [Space]를 누르세요.", 240, 270);
| |
| ctx.fillText("플레이하려면 [Space]를 누르세요.", 240, 360);
| |
| }
| |
| waitToPlayLevel(level, 0);
| |
| }
| |
|
| |
| var waitToPlayLevel = function(level, mode){
| |
| if(keyPress[32]){
| |
| if(levelCount <= level){
| |
| lastLevel();
| |
| return;
| |
| }
| |
| playLevel(level);
| |
| }
| |
| else if(mode==1 && keyPress[38]) playLevel(0);
| |
| else setTimeout(waitToPlayLevel, 100, level, mode);
| |
| }
| |
|
| |
| var lastLevel = function(){
| |
| ctx.fillStyle = "white";
| |
| ctx.fillText("죄송합니다. 더 이상의 레벨이 준비되어 있지 않습니다.", 240, 300);
| |
| ctx.fillText("빠른 시일 내에 새로운 레벨을 준비하겠습니다. 감사합니다.", 240, 340);
| |
| }
| |
|
| |
| main();
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| /** 플러그인 inputform***************************
| |
| * (베타 테스트) 완전한 입력기를 구현합니다.
| |
| * 버전 => 1.6
| |
| * 작성자 : [[사용자:Gustmd7410|Gustmd7410]]
| |
| * JSON => inputform = {"name":"inputform","descript":"(베타 테스트) 완전한 입력기를 구현합니다.","version":"1.6","local":false,"creat":"Gustmd7410","state":"틀:입력 상자/플러그인","executable":true};
| |
| */
| |
| function plugin_inputform(){
| |
| // 이부분에 코드 입력 //
| |
| mw.loader.using('oojs-ui-core').done(function () {
| |
| function toBool(value) {
| |
| switch (value) {
| |
| case undefined: return false;
| |
| case '': return true;
| |
| }
| |
| }
| |
| function toArray(value) {
| |
| if (value)
| |
| return value.split(' ');
| |
| else
| |
| return undefined;
| |
| }
| |
| function InpTable(table) {
| |
| this["case"] = {};
| |
| this["default"] = Object.assign({
| |
| prefix: '',
| |
| value: undefined,
| |
| suffix: '',
| |
| replace: [],
| |
| sub: [0]
| |
| }, table["default"]);
| |
| if (table["case"]) {
| |
| for (var value in table["case"]) {
| |
| this["case"][value] = Object.assign({}, this["default"], { value: this["default"].value || value }, table["case"][value]);
| |
| }
| |
| }
| |
| }
| |
| $('.input-form').each(function () {
| |
| var container = this;
| |
| $(this).html(new $('<form />', {
| |
| "class": $(this).data('class'),
| |
| id: $(this).data('id'),
| |
| style: $(this).data('style'),
| |
| 'accept-charset': 'UTF-8',
| |
| autocomplete: toBool($(this).data('autocomplete')),
| |
| novalidate: toBool($(this).data('novalidate')),
| |
| html: $(this).html()
| |
| }));
| |
| $(this).children('form').submit(function (event) {
| |
| event.preventDefault();
| |
| var action = new URL('/w/index.php', location);
| |
| if (toBool($(container).data('pass')))
| |
| action.search = location.search;
| |
| if ($(container).data('get'))
| |
| new URLSearchParams($(container).data('get')).forEach(function (value, key) {
| |
| action.searchParams.set(key, value);
| |
| });
| |
| action.searchParams.set('title', $(container).data('title'));
| |
| $(this).children('.input-field').each(function () {
| |
| if (typeof ($(this).data('table')) == 'object') {
| |
| var name = $(this).data('name');
| |
| var rawval = $(this).find('input').val();
| |
| var table = new InpTable($(this).data('table'));
| |
| var cvttbl = table["case"][rawval] || table["default"];
| |
| var cvtval = (cvttbl.value || rawval).slice(cvttbl.sub[0], cvttbl.sub[1]);
| |
| cvttbl.replace.forEach(function (reparr) {
| |
| var regex = reparr[0].substr(1).split('/');
| |
| regex.pop();
| |
| regex = regex.join('/');
| |
| var flag = reparr[0].substr(1).split('/').reverse()[0];
| |
| cvtval = cvtval.replace(new RegExp(regex, flag), reparr[1]);
| |
| });
| |
| action.searchParams.set(name, cvttbl.prefix + cvtval + cvttbl.suffix);
| |
| }
| |
| else
| |
| action.searchParams.set($(this).data('name'), $(this).find('input').val());
| |
| });
| |
| location.href = action.href;
| |
| });
| |
| });
| |
| $('.input-field').each(function () {
| |
| $(this).html(new OO.ui.TextInputWidget({
| |
| accessKey: $(this).data('accessKey'),
| |
| autocomplete: toBool($(this).data('autocomplete')),
| |
| autofocus: toBool($(this).data('autofocus')),
| |
| classes: toArray($(this).data('classes')),
| |
| disabled: toBool($(this).data('disabled')),
| |
| flags: toArray($(this).data('flags')),
| |
| icon: $(this).data('icon'),
| |
| iconTitle: $(this).data('iconTitle'),
| |
| id: $(this).data('id'),
| |
| indicator: $(this).data('indicator'),
| |
| indicatorTitle: $(this).data('indicatorTitle'),
| |
| inputId: $(this).data('inputId'),
| |
| maxLength: Number($(this).data('maxLength')),
| |
| name: $(this).data('name'),
| |
| placeholder: $(this).data('placeholder'),
| |
| readOnly: toBool($(this).data('readOnly')),
| |
| required: toBool($(this).data('required')),
| |
| spellcheck: toBool($(this).data('spellcheck')),
| |
| tabIndex: Number($(this).data('tabIndex')),
| |
| text: $(this).data('text'),
| |
| title: $(this).data('title'),
| |
| type: $(this).data('type'),
| |
| validate: (function(container) {
| |
| if ($(container).data('validatetype') == 'RegExp') {
| |
| var value = $(container).data('validate').substr(1).split('/');
| |
| return RegExp(value[0], value[1]);
| |
| }
| |
| else
| |
| return $(container).data('validate');
| |
| })(this),
| |
| value: $(this).data('value')
| |
| }).$element);
| |
| if(toBool($(this).data('inline'))) $(this).find('*').css({
| |
| display: 'inline',
| |
| width: 'auto'
| |
| });
| |
| });
| |
| $('.input-button').each(function () {
| |
| $(this).html(new OO.ui.ButtonInputWidget({
| |
| accessKey: $(this).data('accessKey'),
| |
| classes: toArray($(this).data('classes')),
| |
| disabled: toBool($(this).data('disabled')),
| |
| flags: toArray($(this).data('flags')),
| |
| framed: toBool($(this).data('framed')),
| |
| icon: $(this).data('icon'),
| |
| iconTitle: $(this).data('iconTitle'),
| |
| id: $(this).data('id'),
| |
| indicator: $(this).data('indicator'),
| |
| indicatorTitle: $(this).data('indicatorTitle'),
| |
| inputId: $(this).data('inputId'),
| |
| label: $(this).data('label'),
| |
| name: $(this).data('name'),
| |
| tabIndex: Number($(this).data('tabIndex')),
| |
| text: $(this).data('text'),
| |
| title: $(this).data('title'),
| |
| type: $(this).data('type'),
| |
| value: $(this).data('value')
| |
| }).$element);
| |
| });
| |
| noPlugin('input');
| |
| });
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
| $( plugin_inputform );
| |
| /* inputform 끝 */
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| /** 플러그인 uncyslide***************************
| |
| * 백괴슬라이드 실행
| |
| * 버전 => 1.1.0
| |
| * 작성자 : [[사용자:BANIP|BANIP]]
| |
| * JSON => uncyslide = {"name":"uncyslide","descript":"백괴슬라이드 실행","version":"1.1.0","local":true,"creat":"BANIP","state":"백괴슬라이드/플러그인","executable":true};
| |
| */
| |
| function plugin_uncyslide(){
| |
| if($("[data-name='uncyslide']").length >= 1){
| |
| // 이부부분에 코드 입력 //
| |
| var slideable = plugin_Slideable();
| |
| var create = slideable.create;
| |
| var execute = slideable.execute;
| |
| var dispose = slideable.dispose;
| |
|
| |
| var rankingSystem = plugin_RankingSystem()("백괴슬라이드/랭킹", function(prev,next){ return Number(prev.time) - Number(next.time)});
| |
| var outputKeys = {time:"소요시간"};
| |
| var startMap = localStorage.getItem("uncySlide/startmap") || 0;
| |
| var game = {
| |
| 0: {
| |
| center: "아래로 밀어주세요.",
| |
| bottom: 1
| |
| },
| |
| 1: {
| |
| center: "오른쪽으로 밀어보세요.",
| |
| right: 2
| |
| },
| |
| 2: {
| |
| center: "어디로 밀어보실래요?",
| |
| top: 3,
| |
| bottom: 3,
| |
| },
| |
| 3: {
| |
| center: "반갑습니다. <br>백괴슬라이드입니다.",
| |
| bottom: 4,
| |
| },
| |
| 4: {
| |
| center: "어디로 당기고 미느냐에 따라, 게임의 결과가 달라집니다.",
| |
| bottom: 5,
| |
| },
| |
| 5: {
| |
| center: "는 개뿔 이겜 시스템만든다고 그런 장황한거 만들 정신머리는 없었습니다",
| |
| bottom: 5.1,
| |
| },
| |
| 5.1: {
| |
| center: "진심 힘들었습니다.",
| |
| bottom: 5.2,
| |
| },
| |
| 5.2: {
| |
| center: "잘했죠?",
| |
| bottom: 5.3,
| |
| },
| |
| 5.3: {
| |
| center: "위로 밀어서 칭찬하거나 아래로 밀어서 욕해주세요.",
| |
| top: 5.4,
| |
| bottom: 5.5,
| |
| },
| |
| 5.4: {
| |
| center: "감사합니다. 헤헤",
| |
| bottom: 6,
| |
| },
| |
| 5.5: {
| |
| center: "흑흑.. 힘들었는데..",
| |
| bottom: 6,
| |
| },
| |
| 6: {
| |
| center: "그래도 미디어위키의 틀에서 벗어난 겜인만큼 최대한 나은 경험을 선사하고자 노력했습니다. 잘부탁드립니다.",
| |
| bottom: function(){
| |
| localStorage.setItem("uncySlide/startmap","main");
| |
| execute("main");
| |
| },
| |
| },
| |
| main: {
| |
| center: "<ul><li>아래: 게임시작</li><li>토론: 위</li><li>설명: 오른쪽</li></ul>",
| |
| bottom: function(){ execute("start",{count:100,time:Date.now()}) },
| |
| top: "debate",
| |
| right: "i0",
| |
| },
| |
| i0: {
| |
| center:"가장자리에 화살표 보이죠?",
| |
| bottom:"i1"
| |
| },
| |
| i1: {
| |
| center:"화면을 넘겨서 드래그해서 진행하는 게임이에요.",
| |
| bottom:"i2"
| |
| },
| |
| i2: {
| |
| center:"원래라면 좀 큰 스케일의 게임으로 만들고 싶었는데..",
| |
| bottom:"i3"
| |
| },
| |
| i3: {
| |
| center:"제 역량이 겜 크기에서 다 드러나네요...",
| |
| bottom:"i4"
| |
| },
| |
| i4: {
| |
| center:"아무쪼록 힘들게 만들었으니 재밌게 즐겨주세요.",
| |
| right:"main"
| |
| },
| |
| debate: function(){
| |
| location.href = "https://game.uncyclopedia.kr/wiki/%ED%86%A0%EB%A1%A0:%EB%B0%B1%EA%B4%B4%EC%8A%AC%EB%9D%BC%EC%9D%B4%EB%93%9C";
| |
| },
| |
| start: function(arg){
| |
| function getRandomDirection(){
| |
| switch( Math.ceil(Math.random() * 4) ){
| |
| case 1: return "top"; break;
| |
| case 2: return "bottom"; break;
| |
| case 3: return "left"; break;
| |
| case 4: return "right"; break;
| |
| }
| |
| }
| |
| function getColorCode(count,maxcount){
| |
| var code = "hsl(" + count / maxcount * 360 +",100%,70%)";
| |
| console.log(code);
| |
| return code
| |
| }
| |
|
| |
| var count = arg.count;
| |
| var maxcount = arg.maxcount || count;
| |
| var time = arg.time;
| |
| var $this = $(this);
| |
| var timerInterval;
| |
| var slideableItem = {
| |
| center: function(){
| |
| var $this = $(this);
| |
| $this.css({
| |
| "background": getColorCode(count,maxcount)
| |
| });
| |
|
| |
| timerInterval = setInterval(function(){
| |
| var overtime = (Date.now() - time) * 0.001;
| |
| var printableTime = overtime.toFixed(2);
| |
| $this.find(".counter").html(printableTime + "초");
| |
| },5)
| |
|
| |
| return "<div class='counter' style='font-size:5vw;'></div><div style='font-size:20vw;'>" + count + "</div>";
| |
| }
| |
| };
| |
|
| |
| slideableItem[getRandomDirection()] = function(){
| |
| clearInterval(timerInterval);
| |
| if(count === 1) return execute("result",{count:count - 1,time:time,maxcount:maxcount});
| |
| execute("start",{count:count - 1,time:time,maxcount:maxcount})
| |
| };
| |
|
| |
| create(slideableItem);
| |
| },
| |
| result: function(arg){
| |
| var maxcount = arg.maxcount || count;
| |
| var time = ( (Date.now() - arg.time) / 1000 ).toFixed(2);
| |
| var updateParam = {
| |
| time: time,
| |
| name: mw.config.get("wgUserName")
| |
| };
| |
| rankingSystem.update(updateParam,function(rankingScore,thisScore){ return rankingScore.time > thisScore.time},outputKeys);
| |
|
| |
| create({
| |
| center: "갯수: " + maxcount + " <br/>시간: " + time + "<ul><li>왼쪽: 메인으로</li><li>오른쪽: 토론으로</li></ul>",
| |
| left:"main",
| |
| right:"debate",
| |
| });
| |
| }
| |
| }
| |
| dispose(game, startMap, {});
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_uncyslide );
| |
| /* uncyslide 끝 */
| |
|
| |
|
| |
|
| |
| /** 플러그인 Slideable***************************
| |
| * 슬라이드 플러그인 라이브러리
| |
| * 버전 => 1.0.0
| |
| * 작성자 : [[사용자:BANIP|BANIP]]
| |
| * JSON => Slideable = {"name":"Slideable","descript":"슬라이드 플러그인 라이브러리","version":"1.0.0","local":true,"creat":"BANIP","state":"사용자:BANIP/플러그인/슬라이드","executable":false};
| |
| */
| |
| function plugin_Slideable(){
| |
| if($("[data-name='Slideable']").length >= 1){
| |
| // 이부부분에 코드 입력 //
| |
| //모든 키 순회
| |
| function forEach(object, callback) {
| |
| for (var key in object) {
| |
| var variable = object[key];
| |
| callback(variable, key);
| |
| }
| |
| }
| |
|
| |
| function create(directionData) {
| |
| function initClassName($target, data) {
| |
| forEach(data, function(value, direction) {
| |
| $target.find("." + direction).addClass("on");
| |
| })
| |
| }
| |
|
| |
| function initDOM($target, data) {
| |
| $target[0].data = data;
| |
| $target.find(".center").html(data.center);
| |
| $target.find(".top.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/8/85/Arrow_top_svg.svg') no-repeat center");
| |
| $target.find(".bottom.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/f/f2/Arrow_bottom_svg.svg') no-repeat center");
| |
| $target.find(".left.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/4/40/Arrowleft_svg.svg') no-repeat center");
| |
| $target.find(".right.on").css("background","url('https://upload.wikimedia.org/wikipedia/commons/9/96/Arrow2right_svg.svg') no-repeat center");
| |
| }
| |
|
| |
| var slideUtil = {
| |
| moveObject: function($this, axis) {
| |
| var x = axis[0], y = axis[1];
| |
|
| |
| var data = $this[0].data;
| |
| if (!data.right && x > 0) x = 0;
| |
| if (!data.left && x < 0) x = 0;
| |
| if (!data.top && y < 0) y = 0;
| |
| if (!data.bottom && y > 0) y = 0;
| |
| $this.css("transform", "translate(" + x + "px," + y + "px)");
| |
| },
| |
| isHideable: function($this, axis, limit) {
| |
| var x = axis[0], y = axis[1];
| |
| var data = $this[0].data;
| |
| if (data.right && x > limit) return "right";
| |
| if (data.left && x < limit * -1) return "left";
| |
| if (data.bottom && y > limit) return "bottom";
| |
| if (data.top && y < limit * -1) return "top";
| |
| },
| |
| hide: function(direction, $this) {
| |
| function getCss(direction) {
| |
| var css = {
| |
| opacity: 0.01
| |
| };
| |
| var interval = 50;
| |
| switch (direction) {
| |
| case "left":
| |
| css.left = -1 * interval + "vw";
| |
| break;
| |
| case "right":
| |
| css.left = interval + "vw";
| |
| break;
| |
| case "bottom":
| |
| css.top = interval + "vh";
| |
| break;
| |
| case "top":
| |
| css.top = -1 * interval + "vh";
| |
| break;
| |
| }
| |
|
| |
| return css;
| |
| }
| |
|
| |
| var self = $this[0];
| |
| var data = self.data;
| |
| if (self.isHide === true) {
| |
| return;
| |
| }
| |
| self.isHide = true;
| |
| $this.animate(getCss(direction), {
| |
| duration: 300,
| |
| easing: "swing",
| |
| start: data[direction],
| |
| complete: function() {
| |
| $this.remove();
| |
| }
| |
| });
| |
| }
| |
| }
| |
|
| |
| function setEvent($target, data) {
| |
| var util = slideUtil;
| |
| var moveLimit = 50;
| |
|
| |
| $(".slideable").mousedown(function(e) {
| |
| this.isMouseDown = true;
| |
| this.startAxis = [e.clientX, e.clientY];
| |
| })
| |
|
| |
| $(".slideable").mousemove(function(e) {
| |
| if (this.isMouseDown) {
| |
| event.preventDefault()
| |
| var axis = [e.clientX, e.clientY];
| |
| var startAxis = this.startAxis;
| |
| var moveInterval = [axis[0] - startAxis[0], axis[1] - startAxis[1]]
| |
| util.moveObject($(this), moveInterval);
| |
| var hideDirection = util.isHideable($(this), moveInterval, moveLimit);
| |
| console.log(hideDirection)
| |
| if (hideDirection) util.hide(hideDirection, $(this));
| |
| }
| |
| })
| |
|
| |
| $(".slideable").mouseup(function(e) {
| |
| this.isMouseDown = false;
| |
| })
| |
|
| |
| function getTouchEvent(e) {
| |
| return e.originalEvent.touches[0]
| |
| }
| |
|
| |
| $(".slideable").on("touchstart", function(e) {
| |
| var touch = getTouchEvent(e);
| |
|
| |
| this.isMouseDown = true;
| |
| this.startAxis = [touch.clientX, touch.clientY];
| |
| })
| |
|
| |
| $(".slideable").on("touchmove", function(e) {
| |
| event.preventDefault()
| |
| if (this.isMouseDown) {
| |
| event.preventDefault()
| |
| var touch = getTouchEvent(e);
| |
| var axis = [touch.clientX, touch.clientY];
| |
| var startAxis = this.startAxis;
| |
| var moveInterval = [axis[0] - startAxis[0], axis[1] - startAxis[1]]
| |
| util.moveObject($(this), moveInterval);
| |
| var hideDirection = util.isHideable($(this), moveInterval, moveLimit);
| |
| console.log(hideDirection)
| |
| if (hideDirection) util.hide(hideDirection, $(this));
| |
| }
| |
| })
| |
|
| |
| $(".slideable").on("touchend", function(e) {
| |
| this.isMouseDown = false;
| |
| })
| |
|
| |
| }
| |
|
| |
| //슬라이드아이템의 방향키로 숫자 혹은 문자로 지정된 경우
| |
| //함수로 변환
| |
| function setExecutable(target, item){
| |
| forEach(item,function(value,direction){
| |
| new Promise(function(resolve, reject){
| |
| if(direction === "center"){
| |
| switch( typeof value ){
| |
| case "function":
| |
| resolve( value.bind(target)() );
| |
| break;
| |
| }
| |
| } else {
| |
| switch( typeof value ){
| |
| case "string": case "number":
| |
| resolve(function(){ execute(value); }.bind(target));
| |
| break;
| |
| }
| |
| }
| |
| }).then(function(result){
| |
| item[direction] = result;
| |
| })
| |
|
| |
| })
| |
| }
| |
|
| |
| var $target = $(".slideable.cloneable").clone().removeClass("cloneable");
| |
| $("body").prepend($target);
| |
| setExecutable($target[0], directionData);
| |
| initClassName($target, directionData);
| |
| initDOM($target, directionData);
| |
| setEvent($target, directionData);
| |
| }
| |
|
| |
| // create는 다른 함수들에 의존하지 않음 //
| |
| var game;
| |
|
| |
| function execute(number, argument) {
| |
| dispose(game, number, argument);
| |
| }
| |
|
| |
| function dispose(slideableArray, start, argument) {
| |
| game = slideableArray;
| |
|
| |
| var slideableItem = slideableArray[start];
| |
| console.log(slideableItem);
| |
| switch (typeof slideableItem) {
| |
| case "function":
| |
| slideableItem(argument);
| |
| break;
| |
| case "object":
| |
| create(slideableItem);
| |
| break;
| |
| }
| |
| }
| |
|
| |
| //모바일 전체화면으로 수정
| |
| var setFullScreen = (function(){
| |
| //window.scrollTo(0,1);
| |
| })();
| |
|
| |
| return {
| |
| create: create,
| |
| execute: execute,
| |
| dispose: dispose
| |
| }
| |
|
| |
| }
| |
|
| |
| }
| |
| /* Slideable 끝 */
| |
|
| |
|
| |
|
| |
| /** 플러그인 RankingSystem***************************
| |
| * 랭킹시스템 라이브러리
| |
| * 버전 => 1.0.7
| |
| * 작성자 : [[사용자:BANIP|BANIP]]
| |
| * JSON => RankingSystem = {"name":"RankingSystem","descript":"랭킹시스템 라이브러리","version":"1.0.7","local":true,"creat":"BANIP","state":"사용자:BANIP/플러그인/랭킹시스템","executable":false};
| |
| */
| |
| function plugin_RankingSystem(){
| |
| if($("[data-name='RankingSystem']").length >= 1){
| |
| // 이부부분에 코드 입력 //
| |
|
| |
| /**
| |
| * @param
| |
| {string} documentTitle 랭킹정보가 있는 문서의 제목.
| |
| {function} sortCallback 랭킹을 정렬할때 기준으로 사용하는 함수
| |
| {any} prev 랭킹 정렬 기준으로 사용할 왼쪽의 값
| |
| {any} next 랭킹 정렬 기준으로 사용할 오른쪽의 값
| |
| {object} api MediaWikiapi의 인스턴스, 없어도 됨.
| |
|
| |
| @return {Object}
| |
| {function} get 랭킹정보를 object형태로 획득
| |
| {function} update 랭킹정보 업데이트
| |
| {object} updateInfo 업데이트할 사용자 정보
| |
| {function} updateCriteria 사용자정보의 업데이트 기준
| |
| @param {any} rankingScore 랭킹에서 사용중인 스코어
| |
| {any} thisScore 사용자 스코어
| |
| @return{bool} true가 반환되면 업데이트
| |
| {object} alternateKeys 랭킹에서 보여지는 대체 키
| |
| */
| |
| return function(documentTitle, sortCallback, api) {
| |
| function forEach(object, callback) {
| |
| for (var key in object) {
| |
| var variable = object[key];
| |
| callback(variable, key);
| |
| }
| |
| }
| |
|
| |
| function getRankingJSON(rankingDoc) {
| |
| console.log(rankingDoc)
| |
| if (!rankingDoc) return {};
| |
| var regexp = /\<includeonly\>(.*)\<\/includeonly\>/;
| |
| var stringRanking = regexp.exec(rankingDoc)[1];
| |
| return JSON.parse(stringRanking);
| |
| }
| |
|
| |
| function updateDoc(rankingJSON, api, alternateKeys) {
| |
| //alternateKeys가 반영된 개개인의 랭킹정보 획득
| |
| function getOutputJSON(json) {
| |
| var result = {};
| |
| forEach(json, function(value, key) {
| |
| key = alternateKeys[key] || key;
| |
| result[key] = value;
| |
| })
| |
| return result;
| |
| }
| |
|
| |
| //보여지는 형태의 랭킹정보 획득
| |
| function getOutputString(json) {
| |
| var name = json.name;
| |
| var result = "* '''" + name + "''' : ";
| |
| forEach(json, function(value, key) {
| |
| if (key === "name") return;
| |
| key = alternateKeys[key] || key;
| |
| result += key + ": " + value + ", ";
| |
| })
| |
| result += "\n"
| |
| return result
| |
| }
| |
|
| |
| var stringRanking = JSON.stringify(rankingJSON);
| |
| var result = "<includ" + "eonly>" + stringRanking + "</inclu" + "deonly>\n";
| |
| result += "<onlyin" + "clude>\n";
| |
|
| |
| var rankingList = Object.entries(rankingJSON).sort(function(prev,next){
| |
| return sortCallback(prev[1],next[1])
| |
| }).map(function(value){
| |
| return value[0]
| |
| });
| |
|
| |
| rankingList.forEach(function(key) {
| |
| var json = rankingJSON[key];
| |
| var outputJSON = getOutputJSON(json);
| |
| result += getOutputString(outputJSON)
| |
| });
| |
|
| |
| result += "</only" + "include>";
| |
| var reply = documentTitle.replace(new RegExp("\/.*"),"") + " 점수 갱신";
| |
| api.changeDocument(documentTitle, reply, result, true);
| |
| return result;
| |
| }
| |
|
| |
| function updateUserScore(rankingJSON, thisScore, updateCriteria) {
| |
| updateCriteria = updateCriteria || function(rankingScore, thisScore) {
| |
| return rankingScore.score < thisScore.score;
| |
| }
| |
|
| |
| var userName = thisScore.name;
| |
| var rankingScore = rankingJSON[userName];
| |
|
| |
| if (!rankingScore || updateCriteria(rankingScore, thisScore)) {
| |
| rankingJSON[userName] = thisScore;
| |
| }
| |
| }
| |
|
| |
| api = api || MediaWikiAPI();
| |
| var userName = mw.config.get("wgUserName");
| |
| var rankingDoc = api.getDocument(documentTitle);
| |
| var rankingJSON = getRankingJSON(rankingDoc);
| |
|
| |
| var actions = {
| |
| get: function() {
| |
| return rankingJSON;
| |
| },
| |
| update: function(updateInfo, updateCriteria, alternateKeys) {
| |
| rankingJSON = actions.get();
| |
| updateUserScore(rankingJSON, updateInfo, updateCriteria);
| |
| updateDoc(rankingJSON, api, alternateKeys);
| |
| }
| |
| }
| |
| return actions;
| |
| }
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| /* RankingSystem 끝 */
| |
|
| |
|
| |
| /** 플러그인 autosave***************************
| |
| * 자동저장 시스템을 위한 플러그인
| |
| * 버전 => 2.0.2
| |
| * 작성자 : [[사용자:Manymaster|Manymaster]]
| |
| * JSON => autosave = {"name":"autosave","descript":"자동저장 시스템을 위한 플러그인","version":"2.0.2","local":false,"creat":"Manymaster","state":"틀:자동저장/플러그인","executable":true};
| |
| */
| |
| function plugin_autosave(){
| |
|
| |
| /* 작동 가능한 네임스페이스 */
| |
| var safeNameSpace = [""];
| |
| /* autosave 편집모드가 아닐 경우 플러그인 종료 */
| |
| var searchParams = geturlSearch(location);
| |
| var isEditMode = searchParams.action === "edit";
| |
| var isAutosaveMode = searchParams.autosave === "1";
| |
| if (!(isEditMode && isAutosaveMode)) return "";
| |
|
| |
| /* 자동 저장하기에 안전한 네임스페이스가 아닌 경우 플러그인 종료 */
| |
| var thisNamespaceNumber = mw.config.get("wgNamespaceNumber");
| |
| var nameSpaceIds = mw.config.get("wgNamespaceIds");
| |
| var isSafeNameSpace = safeNameSpace
| |
| .map(function (namespace) { return nameSpaceIds[namespace]; })
| |
| .some(function (nsNumber) { return nsNumber == thisNamespaceNumber; });
| |
| if (!(isSafeNameSpace)) return "";
| |
|
| |
| /* 자동 인증된 사용자가 아닌 경우 플러그인 종료 */
| |
| var userGroups = mw.config.get('wgUserGroups');
| |
| var autocheck = 0;
| |
| if (userGroups) {
| |
| for (var i = 0; i < userGroups.length; i++) {
| |
| if (userGroups[i] === 'autoconfirmed') {
| |
| autocheck++;
| |
| }
| |
| }
| |
| }
| |
| if (autocheck != 1) return "";
| |
|
| |
| /* 지정된 단락에서 불러오기 */
| |
| var savetempDom = $(".game-autosave");
| |
| if ($(".game-autosave").length === 0)
| |
| throw new Error("autosave => game-autosave를 클래스명으로 가진 돔을 찾을 수 없습니다.");
| |
| var savetemp = $(".game-autosave").html();
| |
|
| |
| /* 문제가 되는 문자열 치환 */
| |
| savetemp = savetemp.replace(/(<([^>]+)>)/ig, "");
| |
| savetemp = savetemp.replace(/\n+/gi, "\n");
| |
| savetemp = savetemp.replace("\n", "");
| |
| savetemp = savetemp.replace(/</gi, "<");
| |
| savetemp = savetemp.replace(/>/gi, ">");
| |
|
| |
| /* 기록, 저장하고 빠져나오기 */
| |
| $("#wpTextbox1").val(savetemp);
| |
| $("#wpSave").click();
| |
| return;
| |
|
| |
| /** 이 플러그인 제작을 도와주신 분들
| |
| * Ver 2 제작자: [[사용자:BANIP|BANIP]]
| |
| * 원 코드 작성자: [[사용자:*devunt]]
| |
| */
| |
|
| |
|
| |
| }
| |
| $( plugin_autosave );
| |
| /* autosave 끝 */
| |
|
| |
|
| |
| /** 플러그인 UncyBeat***************************
| |
| * 버그 수정
| |
| * 버전 => 1.03
| |
| * 작성자 : [[사용자:Bd3076|Bd3076]]
| |
| * JSON => UncyBeat = {"name":"UncyBeat","descript":"버그 수정","version":"1.03","local":true,"creat":"Bd3076","state":"UncyBeat/plugin","executable":true};
| |
| */
| |
| function plugin_UncyBeat(){
| |
| if($("[data-name='UncyBeat']").length >= 1){
| |
| // 이부분에 코드 입력 //
| |
|
| |
|
| |
|
| |
| var getParameters = function (paramName) {
| |
| var returnValue;
| |
|
| |
| var url = location.href;
| |
|
| |
| console.log(url);
| |
|
| |
| if(url[8] == 'f'){
| |
| return 0;
| |
| }
| |
|
| |
| var parameters = (url.slice(url.indexOf('?') + 1, url.length)).split('&');
| |
|
| |
| for (var i = 0; i < parameters.length; i++) {
| |
| var varName = parameters[i].split('=')[0];
| |
| if (varName.toUpperCase() == paramName.toUpperCase()) {
| |
| returnValue = parameters[i].split('=')[1];
| |
| return decodeURIComponent(returnValue);
| |
| }
| |
| }
| |
| };
| |
|
| |
| function updateURLParameter(url, param, paramVal){
| |
| var newAdditionalURL = "";
| |
| var tempArray = url.split("?");
| |
| var baseURL = tempArray[0];
| |
| var additionalURL = tempArray[1];
| |
| var temp = "";
| |
| if (additionalURL) {
| |
| tempArray = additionalURL.split("&");
| |
| for (var i=0; i<tempArray.length; i++){
| |
| if(tempArray[i].split('=')[0] != param){
| |
| newAdditionalURL += temp + tempArray[i];
| |
| temp = "&";
| |
| }
| |
| }
| |
| }
| |
|
| |
| var rows_txt = temp + "" + param + "=" + paramVal;
| |
| return baseURL + "?" + newAdditionalURL + rows_txt;
| |
| }
| |
|
| |
| function Queue(){
| |
| this.arr = [];
| |
| this.s = 0;
| |
| this.e = 0;
| |
| this.size = 0;
| |
| this.front = function(){
| |
| return arr[s];
| |
| }
| |
| this.pop = function(){
| |
| s++;
| |
| size--;
| |
| return;
| |
| }
| |
| this.push = function(k){
| |
| arr[e++] = k;
| |
| size--;
| |
| return;
| |
| }
| |
| this.empty = function(){
| |
| return size==0;
| |
| }
| |
| }
| |
|
| |
| var timer = 0;
| |
| function calculateTimer(){
| |
| timer += 1;
| |
| }
| |
|
| |
| var cvs = document.getElementById('spanArea');
| |
| cvs.innerHTML = "<canvas width='720' height='720' id='spanCanvas'></canvas>"
| |
| var canvas = document.getElementById('spanCanvas');
| |
| var ctx = canvas.getContext('2d');
| |
|
| |
| var level = getParameters('level');
| |
| const levelCount = 1;
| |
|
| |
| const levelNames = [
| |
| 'Dreams'
| |
| ];
| |
|
| |
| const levelMusicLink = [
| |
| 'https://k003.kiwi6.com/hotlink/9f13ktbumx/bensound-dreams.mp3'
| |
| ];
| |
|
| |
| function clearCanvas(){
| |
| ctx.clearRect(0, 0, 720, 720);
| |
| }
| |
|
| |
| function makeGameArea(){
| |
| clearCanvas();
| |
| ctx.strokeStyle = "black";
| |
| ctx.strokeRect(20, 20, 680, 680);
| |
|
| |
| for(var i=0; i<5; i++){
| |
| for(var j=0; j<5; j++){
| |
| ctx.strokeRect(40+i*132, 40+j*132, 112, 112);
| |
| }
| |
| }
| |
| }
| |
|
| |
| function playGameMusic(){
| |
| console.log(level);
| |
| var audioElement = new Audio(levelMusicLink[level]);
| |
| var audio = audioElement.play();
| |
| audioElement.onended = function(){
| |
| setTimeout(levelEnd, 3000);
| |
| };
| |
| setInterval(calculateTimer, 50);
| |
| }
| |
|
| |
| var x = 2;
| |
| var y = 2;
| |
| var color = 0;
| |
|
| |
| var perfect = 0;
| |
| var good = 0;
| |
| var miss = 0;
| |
|
| |
| var score = 0;
| |
|
| |
| function levelEnd(){
| |
| var totalNotes = perfect+good+miss;
| |
| score = (perfect / totalNotes) * 1000000 + (good / totalNotes) * 500000;
| |
| clearInterval(calculateTimer);
| |
| clearInterval(showCursor);
| |
| clearInterval(displayNotes);
| |
|
| |
| console.log(score);
| |
|
| |
| var nowScore = getParameters('progress'+level);
| |
| var maxScore = nowScore < score ? score : nowScore;
| |
| location.href = updateURLParameter(location.href, 'progress'+level, maxScore);
| |
| }
| |
|
| |
| var noteTimer = new Array(5);
| |
| for(var i=0; i<5; i++){
| |
| noteTimer[i] = new Array(5);
| |
| for(var j=0; j<5; j++){
| |
| noteTimer[i][j] = -400;
| |
| }
| |
| }
| |
|
| |
| var noteColor = new Array(5);
| |
| for(var i=0; i<5; i++){
| |
| noteColor[i] = new Array(5);
| |
| }
| |
|
| |
| function showCursor(){
| |
| for(var i=0; i<5; i++){
| |
| for(var j=0; j<5; j++){
| |
| ctx.fillStyle = noteColor[i][j]==0?"red":"blue";
| |
| if(noteTimer[i][j] > 0){
| |
| ctx.fillRect(40+i*132, 40+j*132, (400-noteTimer[i][j]) * 112 / 400, 112);
| |
| }
| |
| else{
| |
| ctx.clearRect(40+i*132, 40+j*132, 112, 112);
| |
| }
| |
| if(i==x && j==y){
| |
| ctx.strokeStyle = color==0?"red":"blue";
| |
| }
| |
| else{
| |
| ctx.strokeStyle = "black";
| |
| }
| |
| ctx.strokeRect(40+i*132, 40+j*132, 112, 112);
| |
| }
| |
| }
| |
| }
| |
|
| |
| function perfect_(x, y){
| |
| perfect++;
| |
| noteTimer[x][y] = -400;
| |
| }
| |
|
| |
| function good_(x, y){
| |
| good++;
| |
| noteTimer[x][y] = -400;
| |
| }
| |
|
| |
| function miss_(x, y){
| |
| miss++;
| |
| }
| |
|
| |
| function onKeyDown(e){
| |
| var ek = e.keyCode;
| |
| console.log(ek);
| |
| if(37 <= ek && ek <= 40){
| |
| if(ek == 37){
| |
| if(x!=0) x--;
| |
| }
| |
| else if(ek==38){
| |
| if(y!=0) y--;
| |
| }
| |
| else if(ek==39){
| |
| if(x!=4) x++;
| |
| }
| |
| else if(ek==40){
| |
| if(y!=4) y++;
| |
| }
| |
| console.log(x + "and" + y);
| |
| var point = Math.abs(noteTimer[x][y]);
| |
| if(point <= 20 && color == noteColor[x][y]){
| |
| perfect_(x, y);
| |
| }
| |
| else if((point <= 40 || noteTimer[x][y] > 20) && color == noteColor[x][y]){
| |
| good_(x, y);
| |
| }
| |
| }
| |
| else if(ek==32){
| |
| color = !color;
| |
| }
| |
| }
| |
|
| |
| window.addEventListener("keydown", onKeyDown, false);
| |
|
| |
| var levelData = [
| |
| "0|2|1|0/21|2|2|0/52|2|3|0/72|2|2|0/101|1|2|0/121|2|2|0/153|3|2|0/172|2|2|0/203|2|1|0/223|2|0|0/256|2|1|0/274|2|2|0/305|2|3|0/323|2|4|0/355|2|3|0/375|2|2|0/406|2|1|0/419|3|1|0/431|3|2|0/443|2|2|0/456|1|2|0/469|1|3|0/481|2|3|0/493|2|2|0/506|2|1|0/519|1|1|0/528|1|2|0/544|2|2|0/558|3|2|0/571|3|3|0/583|2|3|0/595|2|2|0/608|2|1|0/621|1|1|0/633|1|2|0/646|2|2|0/659|3|2|0/672|3|1|0/683|2|1|0/697|2|2|0/709|2|3|0/723|3|3|0/735|3|2|0/749|2|2|0/760|1|2|0/772|1|3|0/784|2|3|0/798|2|2|0/811|2|1|0/823|2|0|0/836|2|1|0/850|2|2|0/862|3|2|0/874|4|2|0/888|3|2|0/900|2|2|0/912|1|2|0/924|0|2|0/936|1|2|0/950|2|2|0/964|2|3|0/976|2|4|0/988|2|3|0/1001|2|2|0/1015|2|1|0/1033|2|2|0/1063|2|3|0/1082|2|2|0/1113|1|2|0/1133|2|2|0/1166|3|2|0/1184|2|2|0/1216|2|1|0/1227|2|0|0/1239|1|0|0/1252|0|0|0/1265|0|1|0/1277|0|2|0/1290|1|2|0/1302|2|2|0/1315|3|2|0/1328|4|2|0/1341|4|3|0/1353|4|4|0/1366|3|4|0/1379|2|4|0/1392|2|3|0/1404|2|2|0/1417|3|2|0/1431|4|2|0/1442|3|2|0/1454|2|2|0/1468|1|2|0/1480|0|2|0/1494|1|2|0/1506|2|2|0/1519|3|2|0/1533|4|2|0/1544|4|1|0/1557|4|0|0/1568|3|0|0/1581|2|0|0/1594|2|1|0/1607|2|2|0/1620|2|3|0/1633|2|4|0/1645|2|3|0/1658|2|2|0/1670|2|1|0/1683|2|0|0/1695|2|1|0/1708|2|2|0/1721|2|3|0/1733|2|4|0/1746|1|4|0/1759|0|4|0/1771|0|3|0/1783|0|2|0/1796|1|2|0/1809|2|2|0/1822|2|1|0/1837|2|0|0/1847|2|1|0/1859|2|2|0/1871|1|2|0/1885|0|2|0/1898|1|2|0/1910|2|2|0/1922|2|3|0/1935|2|4|0/1948|2|3|0/1959|2|2|0/1972|3|2|0/1984|4|2|0/1998|3|2|0/2010|2|2|0/2024|2|1|0/2042|2|0|0/2073|1|0|0/2091|0|0|0/2121|0|1|0/2142|0|2|0/2173|1|2|0/2193|2|2|0/2225|3|2|0/2244|4|2|0/2277|4|3|0/2295|4|4|0/2326|3|4|0/2345|2|4|0/2380|2|3|0/2396|2|2|0/2427|1|2|0/2445|0|2|0/2477|1|2|0/2496|2|2|0/2528|3|2|0/2547|4|2|0/2578|3|2|0/2597|2|2|0/2629|2|3|0/2655|2|2|0/2680|2|1|0/2705|2|2|0/2730|1|2|0/2754|2|2|0/2781|3|2|0/2804|2|2|0/2832|2|3|0/2841|3|3|0/2850|3|2|0/2856|3|1|0/2863|2|1|0/2866|1|1|0/2880|1|2|0/2891|1|3|0/2900|2|3|0/2907|3|3|0/2912|4|3|0/2932|3|3|0/2941|2|3|0/2951|1|3|0/2957|1|2|0/2961|1|1|0/2963|1|0|0/2982|2|0|0/2991|2|1|0/3001|2|2|0/3034|1|2|0/3044|0|2|0/3052|1|2|0/3059|2|2|0/3063|3|2|0/3069|3|3|0/3084|2|3|0/3095|2|2|0/3104|2|1|0/3109|1|1|0/3112|0|1|0/3115|0|2|0/3118|0|3|0/3134|1|3|0/3144|2|3|0/3152|2|2|0/3155|2|1|0/3158|2|0|0/3160|3|0|0/3185|3|1|0/3195|3|2|0/3202|2|2|0/3205|1|2|0/3208|1|3|0/3211|2|3|0/3236|2|2|0/3254|2|1|0/3285|2|2|0/3304|2|3|0/3330|2|2|0/3336|1|2|0/3356|2|2|0/3387|2|1|0/3406|2|2|0/3436|3|2|0/3457|2|2|0/3487|1|2|0/3507|2|2|0/3538|2|1|0/3557|2|2|0/3589|2|3|0/3608|2|2|0/3639|1|2|0/3660|2|2|0/3691|3|2|0/3712|2|2|0/3741|2|1|0/3759|2|2|0/3791|2|3|0/3810|2|2|0/3842|1|2|0/3860|2|2|0/3892|3|2|0/3912|2|2|0/3943|2|1|0/3960|2|2|0/3991|2|3|0/4011|2|2|0/4045|1|2|0/4063|2|2|0/4093|3|2|0/4113|2|2|0/"
| |
| ];
| |
|
| |
| var startIndex = 0;
| |
| var endIndex = 0;
| |
| var data;
| |
| var dataLength;
| |
|
| |
| function calculateNotes(t, x, y, c){
| |
| noteTimer[x][y] = 400;
| |
| noteColor[x][y] = c;
| |
| }
| |
|
| |
| function displayNotes(){
| |
| for(var i=0; i<5; i++){
| |
| for(var j=0; j<5; j++){
| |
| if(noteTimer[i][j] != -400) noteTimer[i][j] -= 20;
| |
| if(noteTimer[i][j] < -40 && noteTimer[i][j] != -400){
| |
| noteTimer[i][j] = -400;
| |
| miss_(i, j);
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
| function setInit(){
| |
| data = levelData[level];
| |
| dataLength = String(data).length;
| |
| }
| |
|
| |
| function playNotes(){
| |
| setInterval(displayNotes, 20);
| |
|
| |
| console.log(dataLength + ', ' + data);
| |
|
| |
| for(; endIndex < dataLength;){
| |
| var tt, tx, ty, tc;
| |
| while(data[endIndex] != '|') endIndex++;
| |
| tt = data.substring(startIndex, endIndex);
| |
| startIndex = ++endIndex;
| |
| while(data[endIndex] != '|') endIndex++;
| |
| tx = data.substring(startIndex, endIndex);
| |
| startIndex = ++endIndex;
| |
| while(data[endIndex] != '|') endIndex++;
| |
| ty = data.substring(startIndex, endIndex);
| |
| startIndex = ++endIndex;
| |
| while(data[endIndex] != '/') endIndex++;
| |
| tc = data.substring(startIndex, endIndex);
| |
| startIndex = ++endIndex;
| |
|
| |
| console.log(tt + ', ' + tx + ', ' + ty + ', ' + tc);
| |
|
| |
| setTimeout(calculateNotes, tt*50-400+3100, tt, tx, ty, tc);
| |
| }
| |
| }
| |
|
| |
| function playGame(){
| |
| makeGameArea();
| |
| setInterval(showCursor, 30);
| |
| setTimeout(playGameMusic, 3000);
| |
| setInit();
| |
| playNotes();
| |
| }
| |
|
| |
| playGame();
| |
|
| |
|
| |
|
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_UncyBeat );
| |
| /* UncyBeat 끝 */
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| /** 플러그인 testOfSomething***************************
| |
| * 플러그인의 용도
| |
| * 버전 => 0.02
| |
| * 작성자 : [[사용자:bd3076|bd3076]]
| |
| * JSON => testOfSomething = {"name":"testOfSomething","descript":"플러그인의 용도","version":"0.02","local":false,"creat":"bd3076","state":"사용자:Bd3076/그냥/plugin2","executable":true};
| |
| */
| |
| function plugin_testOfSomething(){
| |
| // 이부분에 코드 입력 //
| |
|
| |
| var dataOfSomethingStrange = "1";
| |
|
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
| $( plugin_testOfSomething );
| |
| /* testOfSomething 끝 */
| |
|
| |
|
| |
| /** 플러그인 msgame***************************
| |
| * 스톱워치 게임
| |
| * 버전 => 0.942
| |
| * 작성자 : [[사용자:Riemann|Riemann]]
| |
| * JSON => msgame = {"name":"msgame","descript":"스톱워치 게임","version":"0.942","local":true,"creat":"Riemann","state":"사용자:Riemann/msgame","executable":true};
| |
| */
| |
| function plugin_msgame(){
| |
| if($("[data-name='msgame']").length >= 1){
| |
| // 이부분에 코드 입력 //
| |
| sc = 0
| |
| cb = 0
| |
|
| |
| bl = false;
| |
| $(document.body).keydown(function() {
| |
| if (bl == false) {
| |
| bl = true
| |
| startF();
| |
| } else {
| |
| bl = false
| |
| stopF();
| |
| }
| |
| });
| |
|
| |
| $("#msgame-start").click(function() {
| |
| bl = true
| |
| startF();
| |
| });
| |
|
| |
| $("#msgame-stop").click(function() {
| |
| bl = false
| |
| stopF();
| |
| });
| |
|
| |
| function startF() {
| |
| obj = Math.floor(Math.random() * 10) + 5;
| |
| $("#msgame-start").css("display", "none");
| |
| $("#msgame-stop").css("display", "block");
| |
| it = new Date();
| |
| si = setInterval(clockUpdate, 20)
| |
| $("#msgame-console").text(obj + " 초를 세세요.");
| |
| }
| |
|
| |
| function stopF() {
| |
| $("#msgame-clockText").css("display", "inline");
| |
| $("#msgame-stop").css("display", "none");
| |
| $("#msgame-start").css("display", "block");
| |
| clearInterval(si);
| |
| ie = new Date();
| |
| ifin = ie - it;
| |
| $("#msgame-clockText").text(toMilliSec(ifin));
| |
| finished(obj, ifin);
| |
| }
| |
|
| |
| function clockUpdate() {
| |
| ic = new Date();
| |
| id = ic - it;
| |
| ii = toMilliSec(id);
| |
| $("#msgame-clockText").text(ii);
| |
| if (obj * 1000 - id < 500 * cb && cb > 4 ) {
| |
| $("#msgame-clockText").fadeOut();
| |
| }
| |
| }
| |
|
| |
| function toMilliSec(d) {
| |
| return (Math.floor(d / 1000) + "\"" + ("" + d % 1000).padStart(3, "0")).padStart(6, "0");
| |
| }
| |
|
| |
| function finished(a, b) {
| |
| ath = a * 1000
| |
| if (ath == b) {
| |
| cbm = Math.floor(Math.pow(800, (1 + cb / 10)))
| |
| $("#msgame-console").text("정확하시군요. " + cbm + " 점 드리겠습니다.");
| |
| sc += cbm
| |
| cb += 1
| |
| } else if (Math.abs(ath - b) < 100) {
| |
| cbm = Math.floor(Math.pow((500 / Math.abs(ath - b)), (1 + cb / 10)))
| |
| $("#msgame-console").text("정확하시군요. " + cbm + " 점 드리겠습니다.");
| |
| sc += cbm
| |
| cb += 1
| |
| } else {
| |
| $("#msgame-console").text("안타깝습니다. 조금 더 노력해 보세요!");
| |
| cb = 0
| |
| }
| |
| $("#msgame-score").text(sc);
| |
| $("#msgame-combo").text(cb);
| |
| }
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_msgame );
| |
| /* msgame 끝 */
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
| /** 플러그인 jsINPUT***************************
| |
| * 입력기
| |
| * 버전 => 1.1
| |
| * 작성자 : [[사용자:Cheongseong9473|Cheongseong9473]]
| |
| * JSON => jsINPUT = {"name":"jsINPUT","descript":"입력기","version":"1.1","local":true,"creat":"Cheongseong9473","state":"자바월드/틀안쓰는입력기/플러그인","executable":true};
| |
| */
| |
| function plugin_jsINPUT(){
| |
| if($("[data-name='jsINPUT']").length >= 1){
| |
| var inptnm;
| |
| inptnm = prompt("입력기","입력 해 보세요!");
| |
| location.replace("https://game.uncyclopedia.kr/wiki/자바월드/틀안쓰는입력기?inpval="+inptnm);
| |
|
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_jsINPUT );
| |
| /* jsINPUT 끝 */
| |
|
| |
|
| |
| /** 플러그인 Bd3076_lab_001***************************
| |
| * test
| |
| * 버전 => 0.11
| |
| * 작성자 : [[사용자:Bd3076|Bd3076]]
| |
| * JSON => Bd3076_lab_001 = {"name":"Bd3076_lab_001","descript":"test","version":"0.11","local":true,"creat":"Bd3076","state":"사용자:Bd3076/대규모 실험실/1/plugin","executable":true};
| |
| */
| |
| function plugin_Bd3076_lab_001(){
| |
| if($("[data-name='Bd3076_lab_001']").length >= 1){
| |
| // 이부분에 코드 입력 //
| |
| function makeTransparentChangeValue(id, value){
| |
| if(value < 0){
| |
| document.getElementById(id).style.display = "none";
| |
| }
| |
| else{
| |
| document.getElementById(id).style.opacity = value/100;
| |
| setTimeout(makeTransparentChangeValue, 10, id, value-1);
| |
| }
| |
| }
| |
|
| |
| function makeTransparent(id){
| |
| makeTransparentChangeValue(id, 100);
| |
| }
| |
|
| |
| function makeTransparentList(idList){
| |
| for(var i=0; i<idList.length; i++){
| |
| setTimeout(makeTransparent, i*1000, idList[i]);
| |
| }
| |
| }
| |
|
| |
| var myIdList = [
| |
| 'p-lang-label',
| |
| 'p-lang',
| |
| 't-info',
| |
| 't-permalink',
| |
| 't-print',
| |
| 't-specialpages',
| |
| 't-upload',
| |
| 't-userrights',
| |
| 't-emailuser',
| |
| 't-log',
| |
| 't-contributions',
| |
| 't-recentchangeslinked',
| |
| 't-whatlinkshere',
| |
| 'p-tb-label',
| |
| 'p-tb'
| |
| ];
| |
|
| |
| makeTransparentList(myIdList);
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_Bd3076_lab_001 );
| |
| /* Bd3076_lab_001 끝 */
| |
|
| |
|
| |
| /** 플러그인 makeflatformembed***************************
| |
| * test
| |
| * 버전 => 1
| |
| * 작성자 : [[사용자:BANIP|BANIP]]
| |
| * JSON => makeflatformembed = {"name":"makeflatformembed","descript":"test","version":"1","local":true,"creat":"BANIP","state":"사용자:BANIP/commonjs","executable":true};
| |
| */
| |
| function plugin_makeflatformembed(){
| |
| if($("[data-name='makeflatformembed']").length >= 1){
| |
| // 이부분에 코드 입력 //
| |
| $("#mw-parser-output").append("<embed src='https://byongshine.tk/survey/uncy' />")
| |
| $(".mw-parser-output").append("<embed src='https://byongshine.tk/survey/uncy' width=1024 height=768 />")
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_makeflatformembed );
| |
| /* makeflatformembed 끝 */
| |
|
| |
|
| |
| /** 플러그인 SimMD5***************************
| |
| * 마법의 MD-5 시뮬레이터 게임에 사용되는 스크립트로, 인터페이스와 배틀시스템을 구현합니다.
| |
| * 버전 => 1.2
| |
| * 작성자 : [[사용자:Gustmd7410|Gustmd7410]]
| |
| * JSON => SimMD5 = {"name":"SimMD5","descript":"마법의 MD-5 시뮬레이터 게임에 사용되는 스크립트로, 인터페이스와 배틀시스템을 구현합니다.","version":"1.2","local":true,"creat":"Gustmd7410","state":"마법의 MD-5 시뮬레이터/플러그인","executable":true};
| |
| */
| |
| function plugin_SimMD5(){
| |
| if($("[data-name='SimMD5']").length >= 1){
| |
| // 이부분에 코드 입력 //
| |
| mw.loader.using('oojs-ui-widgets').done(function() {
| |
| function prepare() {
| |
| function responsible(event) {
| |
| var button = $('#input-time .oo-ui-numberInputWidget-plusButton, #input-time .oo-ui-numberInputWidget-minusButton');
| |
|
| |
| if(event.matches) {
| |
| button.css('display', 'none');
| |
| input.time.$label.css('margin-right', null);
| |
| } else {
| |
| button.css('display', 'null');
| |
| input.time.$label.css('margin-right', '30px');
| |
| }
| |
| }
| |
|
| |
| function encode(string) {
| |
| return string
| |
| .replace(/&/g, '&')
| |
| .replace(/</g, '<')
| |
| .replace(/>/g, '>')
| |
| .replace(/{/g, '{')
| |
| .replace(/\|/g, '|')
| |
| .replace(/=/g, '=')
| |
| .replace(/}/g, '}')
| |
| .replace(/\[/g, '[')
| |
| .replace(/\]/g, ']')
| |
| .replace(/_/g, '_');
| |
| }
| |
|
| |
| function cancel(btn) {
| |
| if(stat.length) {
| |
| battle.done = null;
| |
| battle.turn = 0;
| |
| battle.attack = null;
| |
| battle.sequence = null;
| |
| battle.total = null;
| |
| battle.temp = null;
| |
|
| |
| bar = [];
| |
| bar[0] = new OO.ui.ProgressBarWidget({
| |
| progress: 100
| |
| });
| |
| bar[1] = new OO.ui.ProgressBarWidget({
| |
| progress: 100
| |
| });
| |
|
| |
| bar[0].$bar.css({
| |
| background: '#3366CC'
| |
| });
| |
| bar[0].$element.css({
| |
| 'border-right': 'none',
| |
| 'border-top-right-radius': 0,
| |
| 'border-bottom-right-radius': 0
| |
| });
| |
| bar[1].$bar.css({
| |
| background: '#FF5500'
| |
| });
| |
| bar[1].$element.css({
| |
| 'border-left': 'none',
| |
| 'border-top-left-radius': 0,
| |
| 'border-bottom-left-radius': 0
| |
| });
| |
|
| |
| input.start.setLabel('재시작');
| |
| input.reset.setLabel('초기화');
| |
| $('#stat-turn').text(0);
| |
| $('.stat-0.stat-currentHP').data('value', stat[0].HP).text(stat[0].HP.toFixed(2)).css('color', '#3366CC');
| |
| $('.stat-1.stat-currentHP').data('value', stat[1].HP).text(stat[1].HP.toFixed(2)).css('color', '#FF5500');
| |
| $('.stat-0.stat-HPbar').html(bar[0].$element);
| |
| $('.stat-1.stat-HPbar').html(bar[1].$element);
| |
| if(btn) $('#log')[0].innerText += '\n다시 시작하려면 재시작 버튼을 눌러주세요.';
| |
| }
| |
| }
| |
|
| |
| function stop() {
| |
| clearInterval(battle.work);
| |
|
| |
| $('#input-stop').hide();
| |
| $('#input-start').show();
| |
| input.reset.setDisabled(false);
| |
| input[0].setDisabled(false);
| |
| input[1].setDisabled(false);
| |
| input.time.setDisabled(false);
| |
| input.swap.setDisabled(false);
| |
| }
| |
|
| |
| var input = {};
| |
| input[0] = new OO.ui.TextInputWidget({
| |
| placeholder: '선',
| |
| title: '후',
| |
| value: new URLSearchParams(location.search).get('p0') || ''
| |
| });
| |
| input.start = new OO.ui.ButtonInputWidget({
| |
| type: 'submit',
| |
| flags: ['primary', 'progressive'],
| |
| label: '시작'
| |
| });
| |
| input.stop = new OO.ui.ButtonInputWidget({
| |
| flags: ['primary', 'destructive'],
| |
| label: '정지'
| |
| });
| |
| input[1] = new OO.ui.TextInputWidget({
| |
| placeholder: '후',
| |
| title: '후',
| |
| value: new URLSearchParams(location.search).get('p1') || ''
| |
| });
| |
| input.time = new OO.ui.NumberInputWidget({
| |
| value: 1,
| |
| min: 0,
| |
| label: '초 간격'
| |
| });
| |
| input.reset = new OO.ui.ButtonInputWidget({
| |
| type: 'reset',
| |
| flags: ['destructive'],
| |
| label: '초기화'
| |
| });
| |
| input.swap = new OO.ui.ButtonInputWidget({
| |
| label: $('<div />').css({
| |
| height: '20px',
| |
| width: '20px',
| |
| 'background-image': 'url("/wiki/Special:Redirect/file/Ambox_move_black.svg")',
| |
| 'background-size': 'cover'
| |
| }),
| |
| title: '교체',
| |
| framed: false
| |
| });
| |
| input.table = new OO.ui.ToggleSwitchWidget({
| |
| value: true
| |
| });
| |
| input.icon = new OO.ui.ButtonWidget({
| |
| framed: false,
| |
| icon: $('#mw-customcollapsible-input-option').hasClass('mw-collapsed')? 'expand' : 'collapse'
| |
| });
| |
| input.log = new OO.ui.ButtonWidget({
| |
| label: '기록 복사'
| |
| });
| |
| input.url = new OO.ui.ButtonWidget({
| |
| label: 'URL 복사'
| |
| });
| |
| input.box = new OO.ui.MultilineTextInputWidget();
| |
| var media = matchMedia('(max-width: 800px)');
| |
| var stat = [];
| |
| var bar = [];
| |
| var battle = {
| |
| turn: 0,
| |
| attack: null,
| |
| done: null,
| |
| work: null,
| |
| sequence: null,
| |
| total: null,
| |
| temp: null
| |
| };
| |
|
| |
| $('#input').wrap('<form />');
| |
| $('#input-0').html(input[0].$element);
| |
| $('#input-start').html(input.start.$element);
| |
| $('#input-stop').html(input.stop.$element);
| |
| $('#input-1').html(input[1].$element);
| |
| $('#input-time').html(input.time.$element);
| |
| $('#input-reset').html(input.reset.$element);
| |
| $('#input-swap').html(input.swap.$element);
| |
| $('#input-table').html(input.table.$element).append(' 스탯');
| |
| $('#input-icon').html(input.icon.$element);
| |
| $('#stat-load').html(new OO.ui.ProgressBarWidget().$element);
| |
| $('#log').text('시작하시려면 상단에 대결할 상대의 이름을 입력해 주세요.');
| |
| $('#share-log').html(input.log.$element);
| |
| $('#share-url').html(input.url.$element);
| |
| $('#share-cvbox').html(input.box.$element);
| |
|
| |
| input.box.$input.attr('readonly', '').css('height', '2.5em');
| |
|
| |
| $('#stat-bar').hide();
| |
| $('#share').hide();
| |
|
| |
| responsible(media);
| |
| media.addListener(responsible);
| |
|
| |
| new MutationObserver(function(mutation) {
| |
| input.icon.setIcon($(mutation[0].target).hasClass('mw-collapsed')? 'expand' : 'collapse');
| |
| }).observe($('#mw-customcollapsible-input-option')[0], {
| |
| attributes: true,
| |
| attributeFilter: ['class']
| |
| });
| |
|
| |
| input.swap.$element.click(function() {
| |
| if(!input.swap.disabled) {
| |
| var val = [input[1].value, input[0].value];
| |
| input[0].setValue(val[0]);
| |
| input[1].setValue(val[1]);
| |
|
| |
| if(stat.length) {
| |
| stat = [stat[1], stat[0]];
| |
|
| |
| $('#stat-turn').text(0);
| |
| $('.stat-0').each(function() {
| |
| if($(this).hasClass('stat-name')) $(this).text(stat[0].name);
| |
| else if($(this).hasClass('stat-attack')) $(this).text(stat[0].attack);
| |
| else if($(this).hasClass('stat-quick')) $(this).text(stat[0].quick);
| |
| else if($(this).hasClass('stat-defense')) $(this).text(stat[0].defense);
| |
| else if($(this).hasClass('stat-hit')) $(this).text(stat[0].hit);
| |
| else if($(this).hasClass('stat-luck')) $(this).text(stat[0].luck);
| |
| else if($(this).hasClass('stat-fullHP')) $(this).text(stat[0].HP);
| |
| else if($(this).hasClass('stat-currentHP')) $(this).data('value', stat[0].HP).text(stat[0].HP.toFixed(2));
| |
| else if($(this).hasClass('stat-HPbar')) $(this).html(bar[0].$element);
| |
| });
| |
| $('.stat-1').each(function() {
| |
| if($(this).hasClass('stat-name')) $(this).text(stat[1].name);
| |
| else if($(this).hasClass('stat-attack')) $(this).text(stat[1].attack);
| |
| else if($(this).hasClass('stat-quick')) $(this).text(stat[1].quick);
| |
| else if($(this).hasClass('stat-defense')) $(this).text(stat[1].defense);
| |
| else if($(this).hasClass('stat-hit')) $(this).text(stat[1].hit);
| |
| else if($(this).hasClass('stat-luck')) $(this).text(stat[1].luck);
| |
| else if($(this).hasClass('stat-fullHP')) $(this).text(stat[1].HP);
| |
| else if($(this).hasClass('stat-currentHP')) $(this).data('value', stat[1].HP).text(stat[1].HP.toFixed(2));
| |
| else if($(this).hasClass('stat-HPbar')) $(this).html(bar[1].$element);
| |
| });
| |
|
| |
| var url = new URL(location);
| |
| url.searchParams.set('p0', input[0].value);
| |
| url.searchParams.set('p1', input[1].value);
| |
| history.replaceState(null, '', url);
| |
|
| |
| cancel();
| |
|
| |
| input.start.setLabel('시작');
| |
| }
| |
| }
| |
| });
| |
| input.table.$element.click(function() {
| |
| if(input.table.value) {
| |
| if($('#stat-turn').text()) $('#stat-table').show(500);
| |
| } else {
| |
| $('#stat-table').hide(500);
| |
| }
| |
| });
| |
| input.reset.$button[0].form.addEventListener('reset', function(event) {
| |
| event.preventDefault();
| |
|
| |
| if(!input.reset.disabled) {
| |
| if(battle.done || battle.done === null) {
| |
| var url = new URL(location);
| |
| url.searchParams['delete']('p0');
| |
| url.searchParams['delete']('p1');
| |
| history.replaceState(null, '', url);
| |
| stat = [];
| |
| input[0].setValue();
| |
| input[1].setValue();
| |
| input.time.setValue(1);
| |
| input.table.setValue(true);
| |
| input.start.setLabel('시작');
| |
| $('#share').hide();
| |
| $('#share-cvbox').hide();
| |
| $('#stat-table').hide(500);
| |
| $('#stat-bar').hide(500);
| |
| $('#stat-turn, .stat-0, .stat-1').text('');
| |
| $('#log-time').hide();
| |
| $('#log').show();
| |
| $('#log').text('시작하시려면 상단에 대결할 상대의 이름을 입력해 주세요.');
| |
| $('.stat-HPbar').html('');
| |
| } else cancel(true);
| |
| }
| |
| });
| |
| input.start.$button[0].form.addEventListener('submit', function(event) {
| |
| function last() {
| |
| $('#input-stop').show();
| |
| $('#input-start').hide();
| |
| input.reset.setLabel('취소');
| |
| input[0].setDisabled(true);
| |
| input[1].setDisabled(true);
| |
| input.time.setDisabled(true);
| |
| input.reset.setDisabled(true);
| |
| input.swap.setDisabled(true);
| |
| input.start.setLabel('재개');
| |
|
| |
| battle.work = start(battle, stat.map(function(obj, index) {
| |
| return new Proxy(obj, {
| |
| get: function(target, key, receiver) {
| |
| if(key === 'HP') return +$('.stat-' + index + '.stat-currentHP').data('value');
| |
| else return Reflect.get(target, key, receiver);
| |
| },
| |
| set: function(target, key, value) {
| |
| if(key === 'HP') {
| |
| if(value < 0) {
| |
| value = 0;
| |
| $('.stat-' + index + '.stat-currentHP').css('color', '#000000');
| |
| }
| |
| $('.stat-' + index + '.stat-currentHP').data('value', value).text(value.toFixed(2));
| |
| bar[index].setProgress(value / target.HP * 100);
| |
| }
| |
| }
| |
| });
| |
| }), input.time.value * 1000, function(msg) {
| |
| $('#log')[0].innerText += msg;
| |
| $('#log').scrollTop($('#log')[0].scrollHeight);
| |
|
| |
| if(battle.sequence === 0) {
| |
| $('#stat-turn').text(battle.turn);
| |
| $('.stat-' + battle.attack + '.stat-name').css({
| |
| background: battle.attack? '#FF5500' : '#3366CC',
| |
| color: '#FFFFFF'
| |
| });
| |
| $('.stat-' + (battle.attack ^ 1) + '.stat-name').css({
| |
| background: '#EAECF0',
| |
| color: battle.attack? '#3366CC' : '#FF5500'
| |
| });
| |
| }
| |
| }, function(msg) {
| |
| $('#log')[0].innerText += msg;
| |
| $('#log')[0].innerText += '\n\n백괴스러운 MD-5 시뮬레이터 [https://game.uncyclopedia.kr/wiki/마법의_MD-5_시뮬레이터]';
| |
| $('#log').scrollTop($('#log')[0].scrollHeight);
| |
|
| |
| $('#share').show();
| |
|
| |
| stop();
| |
|
| |
| battle.done = true;
| |
| battle.turn = 0;
| |
| battle.attack = null;
| |
| battle.sequence = null;
| |
| battle.total = null;
| |
| battle.temp = null;
| |
|
| |
| input.start.setLabel('재시작');
| |
| input.reset.setLabel('초기화');
| |
| });
| |
| }
| |
|
| |
| event.preventDefault();
| |
|
| |
| if(!input.start.disabled) {
| |
| $('#share').hide();
| |
| $('#share-cvbox').hide();
| |
|
| |
| if(input.time.value >= 0) {
| |
| $('#log-time').hide();
| |
| $('#log').show();
| |
|
| |
| if(!stat.length) $.get({
| |
| url: '/w/api.php',
| |
| data: {
| |
| action: 'parse',
| |
| format: 'json',
| |
| title: '마법의 MD-5 시뮬레이터',
| |
| text: '[{{#invoke:SimMD5|stat|' + encode(input[0].value) + '|AJAX}},{{#invoke:SimMD5|stat|' + encode(input[1].value) + '|AJAX}}]',
| |
| prop: 'text',
| |
| disablelimitreport: true,
| |
| formatversion: 2
| |
| },
| |
| beforeSend: function() {
| |
| if($('#stat-bar').html()) {
| |
| $('#stat-bar').hide();
| |
| $('#stat-load').show();
| |
| } else $('#stat-load').show(500);
| |
| $('#log').text('스탯 계산중입니다. 잠시만 기다려 주세요.');
| |
|
| |
| var url = new URL(location);
| |
| url.searchParams.set('p0', input[0].value);
| |
| url.searchParams.set('p1', input[1].value);
| |
| history.replaceState(null, '', url);
| |
| },
| |
| success: function(callback) {
| |
| stat = JSON.parse($(callback.parse.text).text());
| |
|
| |
| bar = [];
| |
| bar[0] = new OO.ui.ProgressBarWidget({
| |
| progress: 100
| |
| });
| |
| bar[1] = new OO.ui.ProgressBarWidget({
| |
| progress: 100
| |
| });
| |
|
| |
| bar[0].$bar.css({
| |
| background: '#3366CC'
| |
| });
| |
| bar[0].$element.css({
| |
| 'border-right': 'none',
| |
| 'border-top-right-radius': 0,
| |
| 'border-bottom-right-radius': 0
| |
| });
| |
| bar[1].$bar.css({
| |
| background: '#FF5500'
| |
| });
| |
| bar[1].$element.css({
| |
| 'border-left': 'none',
| |
| 'border-top-left-radius': 0,
| |
| 'border-bottom-left-radius': 0
| |
| });
| |
|
| |
| $('#stat-turn').text(0);
| |
| $('.stat-0').each(function() {
| |
| if($(this).hasClass('stat-name')) $(this).text(stat[0].name);
| |
| else if($(this).hasClass('stat-attack')) $(this).text(stat[0].attack);
| |
| else if($(this).hasClass('stat-quick')) $(this).text(stat[0].quick);
| |
| else if($(this).hasClass('stat-defense')) $(this).text(stat[0].defense);
| |
| else if($(this).hasClass('stat-hit')) $(this).text(stat[0].hit);
| |
| else if($(this).hasClass('stat-luck')) $(this).text(stat[0].luck);
| |
| else if($(this).hasClass('stat-fullHP')) $(this).text(stat[0].HP);
| |
| else if($(this).hasClass('stat-currentHP')) $(this).data('value', stat[0].HP).text(stat[0].HP.toFixed(2));
| |
| else if($(this).hasClass('stat-HPbar')) $(this).html(bar[0].$element);
| |
| });
| |
| $('.stat-1').each(function() {
| |
| if($(this).hasClass('stat-name')) $(this).text(stat[1].name);
| |
| else if($(this).hasClass('stat-attack')) $(this).text(stat[1].attack);
| |
| else if($(this).hasClass('stat-quick')) $(this).text(stat[1].quick);
| |
| else if($(this).hasClass('stat-defense')) $(this).text(stat[1].defense);
| |
| else if($(this).hasClass('stat-hit')) $(this).text(stat[1].hit);
| |
| else if($(this).hasClass('stat-luck')) $(this).text(stat[1].luck);
| |
| else if($(this).hasClass('stat-fullHP')) $(this).text(stat[1].HP);
| |
| else if($(this).hasClass('stat-currentHP')) $(this).data('value', stat[1].HP).text(stat[1].HP.toFixed(2));
| |
| else if($(this).hasClass('stat-HPbar')) $(this).html(bar[1].$element);
| |
| });
| |
|
| |
| $('.stat-0.stat-currentHP').css('color', '#3366CC');
| |
| $('.stat-1.stat-currentHP').css('color', '#FF5500');
| |
|
| |
| $('#stat-load').hide();
| |
| if(input.table.value) $('#stat-table').show(500);
| |
| $('#stat-bar').show();
| |
| $('#log').text('');
| |
| $('#log')[0].innerText += '[' + stat[0].name + '] 공격력: ' + stat[0].attack + ' / 방어력: ' + stat[0].defense + ' / 민첩: ' + stat[0].quick + ' / 명중: ' + stat[0].quick + ' / 운: ' + stat[0].luck + ' / HP: ' + stat[0].HP + '\n';
| |
| $('#log')[0].innerText += '[' + stat[1].name + '] 공격력: ' + stat[1].attack + ' / 방어력: ' + stat[1].defense + ' / 민첩: ' + stat[1].quick + ' / 명중: ' + stat[1].quick + ' / 운: ' + stat[1].luck + ' / HP: ' + stat[1].HP + '\n';
| |
| $('#log')[0].innerText += '\n';
| |
|
| |
| battle.turn = 1;
| |
| battle.done = false;
| |
| battle.attack = 0;
| |
| battle.sequence = 0;
| |
| battle.total = [50, 50];
| |
| battle.temp = {};
| |
|
| |
| last();
| |
| },
| |
| error: function(error) {
| |
| $('#stat-load').hide(500);
| |
| $('#log').text('스탯 계산에 오류가 발생하였습니다. 다시 시도해 주십시오. (' + error.status + ')');
| |
| }
| |
| });
| |
| else if(battle.done || battle.done === null) {
| |
| if(battle.done) cancel();
| |
|
| |
| $('#log').text('');
| |
| $('#log')[0].innerText += '[' + stat[0].name + '] 공격력: ' + stat[0].attack + ' / 방어력: ' + stat[0].defense + ' / 민첩: ' + stat[0].quick + ' / 명중: ' + stat[0].quick + ' / 운: ' + stat[0].luck + ' / HP: ' + stat[0].HP + '\n';
| |
| $('#log')[0].innerText += '[' + stat[1].name + '] 공격력: ' + stat[1].attack + ' / 방어력: ' + stat[1].defense + ' / 민첩: ' + stat[1].quick + ' / 명중: ' + stat[1].quick + ' / 운: ' + stat[1].luck + ' / HP: ' + stat[1].HP + '\n';
| |
| $('#log')[0].innerText += '\n';
| |
|
| |
| battle.turn = 1;
| |
| battle.done = false;
| |
| battle.attack = 0;
| |
| battle.sequence = 0;
| |
| battle.total = [50, 50];
| |
| battle.temp = {};
| |
|
| |
| last();
| |
| } else last();
| |
| } else {
| |
| $('#log-time').show();
| |
| $('#log').hide();
| |
| }
| |
| }
| |
| });
| |
| input.stop.$element.click(function() {
| |
| if(!input.stop.disabled) stop();
| |
| });
| |
| input[0].$input.focus(function() {
| |
| cancel();
| |
| stat = [];
| |
| input.start.setLabel('시작');
| |
| $(this).select();
| |
| });
| |
| input[1].$input.focus(function() {
| |
| cancel();
| |
| stat = [];
| |
| input.start.setLabel('시작');
| |
| $(this).select();
| |
| });
| |
| input.log.$button.click(function() {
| |
| input.box.setValue($('#log').text());
| |
| $('#share-cvbox').show();
| |
| input.box.$input.select();
| |
| document.execCommand('copy');
| |
| });
| |
| input.url.$button.click(function() {
| |
| input.box.setValue(location);
| |
| $('#share-cvbox').show();
| |
| input.box.$input.select();
| |
| document.execCommand('copy');
| |
| });
| |
| input.box.$input.click(function() {
| |
| $(this).select();
| |
| });
| |
| }
| |
|
| |
| function start(battle, stat, time, each, last) {
| |
| function rand(min, max) {
| |
| return Math.floor(Math.random() * (max - min + 1)) + min;
| |
| }
| |
|
| |
| function range(weight) {
| |
| var range = [-0.5, -0.25, 0, 0.25, 0.5].map(function(ratio, index) {
| |
| return 20 + (weight - 50) * ratio;
| |
| });
| |
| range.reduce(function(acc, current, index, prob) {
| |
| return prob[index] += acc;
| |
| });
| |
| return range;
| |
| }
| |
|
| |
| function rank(range, val) {
| |
| return range.findIndex(function(current, index) {
| |
| return (index === 0 || range[index - 1] < val) && val <= current;
| |
| });
| |
| }
| |
|
| |
| function power(stat, rank) {
| |
| return stat * (((rank === 0)? 0 : rand(1 + 25 * (rank - 1), 25 * rank)) / 100);
| |
| }
| |
|
| |
| function bonus(plus, minus, rank) {
| |
| rank -= 2;
| |
| if(rank === 0) return 0;
| |
| return ((rank)? plus : minus) * (rand(1 + 50 * (rank - 1), 50 * rank) / 100);
| |
| }
| |
|
| |
| function josa(text, exist, not, only) {
| |
| text = text.normalize('NFD');
| |
| var code = text.charCodeAt(text.length - 1);
| |
|
| |
| if(0x1161 <= code && code <= 0x11A7) return ((only)? '' : text) + not;
| |
| else if(0x11A8 <= code && code <= 0x11FF) return ((only)? '' : text) + exist;
| |
| else return ((only)? '' : text) + exist + '(' + not + ')';
| |
| }
| |
|
| |
| return setInterval(function() {
| |
| var attacker = battle.attack;
| |
| var defender = attacker ^ 1;
| |
|
| |
| if(stat[0].HP > 0 && stat[1].HP > 0) {
| |
| switch(battle.sequence) {
| |
| case 0:
| |
| var scale = range(stat[attacker].luck);
| |
| var adv = bonus(stat[attacker].hit, stat[defender].quick, rank(range(50), battle.total[attacker]));
| |
| var grade = {
| |
| attack: rank(scale, rand(1, 100)),
| |
| defense: rank(range(stat[defender].luck), rand(1, 100)),
| |
| bonus: adv === 0 && 0 || (adv)? 1 : -1
| |
| };
| |
| var damage = power(stat[attacker].attack, grade.attack) - power(stat[defender].defense, grade.defense) + adv;
| |
| battle.temp = {
| |
| rank: rank(scale, damage),
| |
| damage: (damage > 0)? damage : 0
| |
| };
| |
|
| |
| if(battle.temp.damage > stat[attacker].attack) battle.temp.rank = 5;
| |
| if(battle.temp.damage > 0) {
| |
| if(battle.total[attacker] > 50) {
| |
| battle.total[attacker] = 50;
| |
| battle.total[defender] = 50;
| |
| } else {
| |
| battle.total[attacker]--;
| |
| battle.total[defender]++;
| |
| }
| |
| } else {
| |
| if(battle.total[attacker] < 50) {
| |
| battle.total[attacker] = 50;
| |
| battle.total[defender] = 50;
| |
| } else {
| |
| battle.total[attacker]++;
| |
| battle.total[defender]--;
| |
| }
| |
| }
| |
|
| |
| each('[' + stat[attacker].name + ']의 공격 ');
| |
| battle.sequence++;
| |
| break;
| |
| case 1:
| |
| var rankText = ['MISS', 'HIT', 'GOOD', 'NICE', 'PERFECT', 'CRITICAL'][battle.temp.rank];
| |
| each(rankText + '! ');
| |
| battle.sequence++;
| |
| break;
| |
| case 2:
| |
| stat[defender].HP -= battle.temp.damage;
| |
| var msg = (battle.temp.rank === 0)? '공격을 피했다.' : (+battle.temp.damage.toFixed(2)) + '의 대미지를 받았다.';
| |
| each('[' + stat[defender].name + ']' + josa(stat[defender].name, '은', '는', true) + ' ' + msg + ' (남은 HP: ' + (+stat[defender].HP.toFixed(2)) + ')\n');
| |
| if(attacker === 1) battle.turn++;
| |
| battle.sequence = 0;
| |
| battle.attack = defender;
| |
| break;
| |
| }
| |
| } else last('\n[' + stat[defender].name + '] 승! (' + battle.turn + '턴)');
| |
| }, time);
| |
| }
| |
|
| |
| $(prepare);
| |
| });
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_SimMD5 );
| |
| /* SimMD5 끝 */
| |
|
| |
|
| |
| /** 플러그인 switched_maze***************************
| |
| * 스위치 미로 게임
| |
| * 버전 => 1.0
| |
| * 작성자 : [[사용자:Bd3076|Bd3076]]
| |
| * JSON => switched_maze = {"name":"switched_maze","descript":"스위치 미로 게임","version":"1.0","local":true,"creat":"Bd3076","state":"스위치 미로/plugin","executable":true};
| |
| */
| |
| function plugin_switched_maze(){
| |
| if($("[data-name='switched_maze']").length >= 1){
| |
| // 이부분에 코드 입력 //
| |
|
| |
|
| |
| var keyPress = new Array(128);
| |
|
| |
| document.onkeydown = function(e){
| |
| e = e || window.event;
| |
| keyPress[e.keyCode] = 1;
| |
| }
| |
|
| |
| document.onkeyup = function(e){
| |
| e = e || window.event;
| |
| keyPress[e.keyCode] = 0;
| |
| }
| |
|
| |
| var cvs = document.getElementById("cvs");
| |
| cvs.innerHTML = ('<canvas id="canvas" width="480" height="480"></canvas>')
| |
| var canvas = document.getElementById('canvas');
| |
| var ctx = canvas.getContext('2d');
| |
|
| |
| ctx.fillStyle = "black";
| |
| ctx.fillRect(0, 0, 500, 500);
| |
|
| |
| var stopWatchH = 0;
| |
| var stopWatchM = 0;
| |
| var stopWatchS = 0;
| |
| var stopWatchSS = 0;
| |
|
| |
| var addStopwatch = function(){
| |
| stopWatchSS++;
| |
| if(stopWatchSS == 10){
| |
| stopWatchS++;
| |
| stopWatchSS = 0;
| |
| if(stopWatchS == 60){
| |
| stopWatchM++;
| |
| stopWatchS = 0;
| |
| if(stopWatchM == 60){
| |
| stopWatchH++;
| |
| stopWatchM = 0;
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
| var setStopwatch = function(){
| |
| stopwatchH = 0;
| |
| stopwatchM = 0;
| |
| stopwatchS = 0;
| |
| stopwatchSS = 0;
| |
| setInterval(addStopwatch, 100);
| |
| }
| |
|
| |
| var setCookie = function(name, value) {
| |
| var date = new Date();
| |
| date.setTime(date.getTime() + 12345678987654321);
| |
| document.cookie = name + '=' + value + ';expires=' + date.toUTCString() + ';path=/';
| |
| };
| |
|
| |
| var getCookie = function(name) {
| |
| var value = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
| |
| return value? value[2] : null;
| |
| };
| |
|
| |
| // road variable
| |
| // 2^0: right (+x)
| |
| // 2^1: down (-y)
| |
| // 2^2: left (-x)
| |
| // 2^3: up (+y)
| |
|
| |
| var levelCount = 1;
| |
|
| |
| var levelData = new Array(levelCount);
| |
| levelData[0] = {
| |
| x: 4,
| |
| y: 4,
| |
| startX: 0,
| |
| startY: 0,
| |
| finishX: 1,
| |
| finishY: 0,
| |
| road: [
| |
| [8, 3, 5, 12],
| |
| [11, 4, 1, 14],
| |
| [10, 8, 1, 6],
| |
| [2, 3, 5, 4]
| |
| ],
| |
| switch_road: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [[{dir:1, num:2}], [{dir:4, num:2}],0,0]
| |
| ],
| |
| switch_num: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [2, 0, 0, 0],
| |
| [0, 0, 0, 0]
| |
| ],
| |
| lever_road: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, [{dir:8, num:2}], 0],
| |
| [0, 0, [{dir:2, num:2}], 0]
| |
| ],
| |
| lever: [
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 0],
| |
| [0, 0, 0, 2]
| |
| ],
| |
| lever_point: [
| |
| 0, 0, 3
| |
| ],
| |
| switch_open: [
| |
| 0, 0, 0
| |
| ],
| |
| lever_open: [
| |
| 0, 0, 0
| |
| ]
| |
| };
| |
|
| |
| var levelClear = function(level){
| |
| ctx.fillStyle = "white";
| |
| ctx.fillText("레벨 " + level + " 클리어!", 240, 200);
| |
| ctx.fillText("걸린 시간: " + stopWatchH + "시간 " + stopWatchM + "분 " + stopWatchS + "." + stopWatchSS + "초", 240, 240);
| |
| ctx.fillText("다음 레벨로 넘어가시려면 [Space]를 누르세요.", 240, 280);
| |
| setCookie("level", level+1);
| |
| waitToPlayLevel(level+1);
| |
| }
| |
|
| |
| var displayRoom = function(level, x, y){
| |
| ctx.fillStyle = "black";
| |
| ctx.fillRect(0, 0, 500, 500);
| |
|
| |
| console.log("x: " + x + ", y: " + y + ", road: " + levelData[level].road[y][x]);
| |
|
| |
| if(x == levelData[level].finishX && y == levelData[level].finishY){
| |
| levelClear(level);
| |
| return;
| |
| }
| |
|
| |
| var road = levelData[level].road[y][x];
| |
| var switch_road = levelData[level].switch_road[y][x];
| |
| var switch_num = levelData[level].switch_num[y][x];
| |
| var lever_road = levelData[level].lever_road[y][x];
| |
| var lever = levelData[level].lever[y][x];
| |
|
| |
| var roadRight = (road & 1);
| |
| var roadDown = (road & 2) / 2;
| |
| var roadLeft = (road & 4) / 4;
| |
| var roadUp = (road & 8) / 8;
| |
|
| |
| for(var i=0; i<switch_road.length; i++){
| |
| var t_sdir = switch_road[i].dir;
| |
| if(t_sdir & 1) roadRight = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| if(t_sdir & 2) roadDown = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| if(t_sdir & 4) roadLeft = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| if(t_sdir & 8) roadUp = levelData[level].switch_open[switch_road[i].num] ? 1 : 2;
| |
| }
| |
|
| |
| for(var i=0; i<lever_road.length; i++){
| |
| var t_ldir = lever_road[i].dir;
| |
| if(t_ldir & 1) roadRight = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| if(t_ldir & 2) roadDown = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| if(t_ldir & 4) roadLeft = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| if(t_ldir & 8) roadUp = levelData[level].lever_open[lever_road[i].num] ? 1 : 3;
| |
| }
| |
|
| |
| ctx.fillStyle = "white";
| |
| ctx.fillRect(120, 120, 240, 240);
| |
| if(roadRight){
| |
| ctx.fillStyle = roadRight == 1 ? "white" : roadRight == 2 ? "blue" : "purple";
| |
| ctx.fillRect(360, 180, 120, 120);
| |
| }
| |
| if(roadDown){
| |
| ctx.fillStyle = roadDown == 1 ? "white" : roadDown == 2 ? "blue" : "purple";
| |
| ctx.fillRect(180, 360, 120, 120);
| |
| }
| |
| if(roadLeft){
| |
| ctx.fillStyle = roadLeft == 1 ? "white" : roadLeft == 2 ? "blue" : "purple";
| |
| ctx.fillRect(0, 180, 120, 120);
| |
| }
| |
| if(roadUp){
| |
| ctx.fillStyle = roadUp == 1 ? "white" : roadUp == 2 ? "blue" : "purple";
| |
| ctx.fillRect(180, 0, 120, 120);
| |
| }
| |
|
| |
| if(roadRight == 1) road |= 1;
| |
| if(roadDown == 1) road |= 2;
| |
| if(roadLeft == 1) road |= 4;
| |
| if(roadUp == 1) road |= 8;
| |
|
| |
| setTimeout(waitForKey, 200, level, x, y, road);
| |
|
| |
| if(levelData[level].switch_num[y][x]){
| |
| ctx.fillStyle = "blue";
| |
| if(levelData[level].switch_open[levelData[level].switch_num[y][x]]){
| |
| ctx.fillRect(130, 130, 50, 220);
| |
| }
| |
| else{
| |
| ctx.fillRect(140, 140, 30, 200);
| |
| }
| |
| }
| |
| if(levelData[level].lever[y][x]){
| |
| ctx.fillStyle = "purple";
| |
| if(levelData[level].lever_open[levelData[level].lever[y][x]]){
| |
| ctx.fillRect(300, 130, 50, 220);
| |
| }
| |
| else{
| |
| ctx.fillRect(310, 140, 30, 200);
| |
| }
| |
| }
| |
| }
| |
|
| |
| var counter = 0;
| |
|
| |
| var waitForKey = function(level, x, y, road){
| |
| counter++;
| |
| var canPressSpace;
| |
| if(levelData[level].switch_num[y][x] == 0 && levelData[level].lever[y][x] == 0){
| |
| canPressSpace = 0;
| |
| }
| |
| else{
| |
| canPressSpace = 1;
| |
| }
| |
|
| |
| if((!keyPress[32] || !canPressSpace) &&
| |
| (!keyPress[37] || x==0 || !(road&4)) &&
| |
| (!keyPress[38] || y==levelData[level].y-1 || !(road&8)) &&
| |
| (!keyPress[39] || x==levelData[level].x-1 || !(road&1)) &&
| |
| (!keyPress[40] || y==0 || !(road&2))){
| |
| setTimeout(waitForKey, 30, level, x, y, road);
| |
| counter--;
| |
| return;
| |
| }
| |
| else{
| |
| if(keyPress[32] && canPressSpace){
| |
| console.log("pressed space");
| |
| keyPress[32] = 0;
| |
| if(levelData[level].switch_num[y][x] > 0){
| |
| levelData[level].switch_open[levelData[level].switch_num[y][x]] = 1 - levelData[level].switch_open[levelData[level].switch_num[y][x]];
| |
| displayRoom(level, x, y);
| |
| return;
| |
| }
| |
| if(levelData[level].lever[y][x] > 0){
| |
| levelData[level].lever_open[levelData[level].lever[y][x]] = levelData[level].lever_point[levelData[level].lever[y][x]];
| |
| displayRoom(level, x, y);
| |
| return;
| |
| }
| |
| counter--;
| |
| return;
| |
| }
| |
| else{
| |
| for(var i=0; i<levelData[level].lever_open.length; i++){
| |
| levelData[level].lever_open[i]--;
| |
| if(levelData[level].lever_open[i] < 0) levelData[level].lever_open[i] = 0;
| |
| }
| |
| if(keyPress[37] && x!=0 && road&4){
| |
| console.log("pressed left");
| |
| displayRoom(level, x-1, y);
| |
| keyPress[37] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| else if(keyPress[38] && y!=levelData[level].y-1 && road&8){
| |
| console.log("pressed up");
| |
| displayRoom(level, x, y+1);
| |
| keyPress[38] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| else if(keyPress[39] && x!=levelData[level].x-1 && road&1){
| |
| console.log("pressed down");
| |
| displayRoom(level, x+1, y);
| |
| keyPress[39] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| else if(keyPress[40] && y!=0 && road&2){
| |
| console.log("pressed right");
| |
| displayRoom(level, x, y-1);
| |
| keyPress[40] = 0;
| |
| counter--;
| |
| return;
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
| var playLevel = function(level){
| |
| var thisLevelData = levelData[level];
| |
| setStopwatch();
| |
| addStopwatch();
| |
| console.log(thisLevelData);
| |
| displayRoom(level, thisLevelData.startX, thisLevelData.startY);
| |
| }
| |
|
| |
| var main = function(){
| |
| ctx.font = "15px Dotum";
| |
| ctx.textAlign = "center";
| |
| ctx.fillStyle = "white";
| |
| var level = getCookie("level");
| |
| if(level != null){
| |
| ctx.fillText("저장된 파일이 있습니다. 이어 플레이하시겠습니까?", 240, 200);
| |
| ctx.fillText("예: [Space], 아니오: [↑]", 240, 240);
| |
| waitToPlayLevel(level, 1);
| |
| }
| |
| else{
| |
| level = 0;
| |
| ctx.fillText("표지판 걸린 미로", 240, 120);
| |
| ctx.fillText("Bd3076", 240, 150);
| |
| ctx.fillText("움직이려면 [방향키]를 누르세요.", 240, 240);
| |
| ctx.fillText("스위치나 레버를 누르려면 [Space]를 누르세요.", 240, 270);
| |
| ctx.fillText("플레이하려면 [Space]를 누르세요.", 240, 360);
| |
| }
| |
| waitToPlayLevel(level, 0);
| |
| }
| |
|
| |
| var waitToPlayLevel = function(level, mode){
| |
| if(keyPress[32]){
| |
| if(levelCount <= level){
| |
| lastLevel();
| |
| return;
| |
| }
| |
| playLevel(level);
| |
| }
| |
| else if(mode==1 && keyPress[38]) playLevel(0);
| |
| else setTimeout(waitToPlayLevel, 100, level, mode);
| |
| }
| |
|
| |
| var lastLevel = function(){
| |
| ctx.fillStyle = "white";
| |
| ctx.fillText("죄송합니다. 더 이상의 레벨이 준비되어 있지 않습니다.", 240, 300);
| |
| ctx.fillText("빠른 시일 내에 새로운 레벨을 준비하겠습니다. 감사합니다.", 240, 340);
| |
| }
| |
|
| |
| main();
| |
|
| |
|
| |
|
| |
| // 여기까지 코드 입력 //
| |
|
| |
|
| |
| }
| |
|
| |
| }
| |
| $( plugin_switched_maze );
| |
| /* switched_maze 끝 */
| |