본문으로 이동

사용자:Jinhoftyu/common.js: 두 판 사이의 차이

리버티게임, 모두가 만들어가는 자유로운 게임
Jinhoftyu (토론 | 기여)
편집 요약 없음
태그: 되돌려진 기여
Jinhoftyu (토론 | 기여)
플러그인 p21설치
(같은 사용자의 중간 판 16개는 보이지 않습니다)
1번째 줄: 1번째 줄:




/** 플러그인 uncydungeon***************************
/** 플러그인 p21***************************
* uncydungeon 실행
* 블랙잭
* 버전 => 0.1
* 버전 => 0.840a4
* 작성자 : [[사용자:Jinhoftyu|Jinhoftyu]]  
* 작성자 : [[사용자:Riemann|Riemann]]  
* JSON => uncydungeon = {"name":"uncydungeon","descript":"uncydungeon 실행","version":"0.1","local":true,"creat":"Jinhoftyu","state":"사용자:Jinhoftyu/Undungeon/플러그인","executable":true};  
* JSON => p21 = {"name":"p21","descript":"블랙잭","version":"0.840a4","local":true,"creat":"Riemann","state":"사용자:Riemann/p21","executable":true};  
*/  
*/  
function plugin_uncydungeon(){
function plugin_p21(){
   if($("[data-name='uncydungeon']").length >= 1){
   if($("[data-name='p21']").length >= 1){
// 이부분에 코드 입력 //
var title = mw.config.get('wgPageName');
const readline = require('readline');
if (title.slice( 1, 2 ) == "라") {
    var blind = true;
    var defa = 20;
} else {
    var blind = false;
    var defa = 10;
}
var mult = defa;
$("#multiplier").text(mult);


const rl = readline.createInterface({
var coins = 100;
  input: process.stdin,
var wincount = 0;
  output: process.stdout
var losecount = 0;
});
//$("#console").text("스코어: " + coins + "점");
$("#console").text("스코어: " + wincount + "승 " + losecount + "패");
$("#console").append("\n블랙잭에 오신 것을 환영합니다.");


function Item(type, name, value) {
const pcLst = [
  this.type = type;
0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAD,0xAE,
  this.name = name;
0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBD,0xBE,
  this.value = value;
0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCD,0xCE,
0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDD,0xDE];
const pointData = {a1:1,a2:2,a3:3,a4:4,a5:5,a6:6,a7:7,a8:8,a9:9,aa:10,ab:10,ad:10,ae:10,b1:1,b2:2,b3:3,b4:4,b5:5,b6:6,b7:7,b8:8,b9:9,ba:10,bb:10,bd:10,be:10,c1:1,c2:2,c3:3,c4:4,c5:5,c6:6,c7:7,c8:8,c9:9,ca:10,cb:10,cd:10,ce:10,d1:1,d2:2,d3:3,d4:4,d5:5,d6:6,d7:7,d8:8,d9:9,da:10,db:10,dd:10,de:10};
var pcSet = [];
function hexToChar(x) {
    return String.fromCharCode(0xD83C) +String.fromCharCode(x + 0xDC00);
}
}
 
function hexToStr(x) {
function Entity(type, name, x, y, health) {
    return x.toString(16);
  this.type = type;
  this.name = name;
  this.x = x;
  this.y = y;
  this.health = health;
}
}
 
var dealerD, guestD;
const rand = new (function () {
$("#deal").click(function(){
  var seed = new Date().getTime();
    //$("#console").text("스코어: " + coins + "점");
  this.nextInt = function (n) {
    $("#console").text("스코어: " + wincount + "승 " + losecount + "패");
     return Math.floor(Math.random() * n);
    $("#console").append("\n새 판을 엽니다.");
  };
    $("#deal").css("display", "none");
  this.seed = function (s) {};
    $("#dealerDeck").text("");
})();
     $("#guestDeck").text("");
 
    pcSet = Object.create(pcLst);
var game = false;
    deal();
var mapY = 20;
    return 0;
var mapX = 80;
});
const base = new Array(mapY).fill(null).map(function () {
$("#hit").click(function(){
  return new Array(mapX).fill(null);
    hit();
    return 0;
});
$("#stand").click(function(){
    stand();
    return 0;
});
$("#surrender").click(function(){
    surrender();
    return 0;
});
$("#plus").click(function(){
    inc();
    return 0;
});
$("#minus").click(function(){
    dec();
    return 0;
});
});
const entity = new Array(mapY).fill(null).map(function () {
$("#reset").click(function(){
  return new Array(mapX).fill(null);
    reset();
    return 0;
});
});
const entities = [];
function reset() {
const item = [];
    mult = defa;
 
    $("#multiplier").text(mult);
let dl = 0;
let xl = 0;
let hp = 0;
let maxhp = 0;
let pw = 0;
let maxpw = 0;
let time = 0;
 
let role;
let name = null;
let pl;
const inv = [];
 
const log = [];
 
function refLog() {
  while (log.length > 3) {
    log.shift();
  }
}
}


function main() {
/*
  for (var i = 0; i < mapY; i++) {
function inc() {
    var row = [];
    if (mult < 100) {
     for (var j = 0; j < mapX; j++) {
        mult += 2;
      row.push([]);
     } else {
        alert("최대 100 코인까지만 걸 수 있습니다.");
     }
     }
     item.push(row);
     $("#multiplier").text(mult);
  }
 
  askQuestion('Your name?').then(function (nameInput) {
    name = nameInput;
    chooseRole();
  });
}
}


function chooseRole() {
function dec() {
  if (name === null) {
    if (mult > 2) {
     askQuestion(`
        mult -= 2;
                    Your role?
     } else {
                    a) Monk
        alert("설마 빚을 판돈으로 거시려고요?");
                    b) Ranger
     }
                    c) Valkryie
     $("#multiplier").text(mult);
                    d) Wizard`).then(function (roleInput) {
      preset(roleInput);
     });
  } else {
     preset(null);
  }
}
}
*/


function preset(s) {
function deal() {
  switch (s) {
     dealerD = [];
     case 'a':
     guestD = [];
      role = 'Monk';
     dealerD.push(cardPop());
      maxhp = 20;
     guestD.push(cardPop());
      maxpw = 10;
     dealerD.push(cardPop());
      break;
    guestD.push(cardPop());
     case 'b':
    if (blind == true) {
      role = 'Ranger';
         $("#dealerDeck").text("\u{1F0A0}\u{1F0A0}");
      maxhp = 15;
    } else {
      maxpw = 5;
         $("#dealerDeck").text(hexToChar(dealerD[0]) + "\u{1F0A0}");
      break;
    }
     case 'c':
    $("#dealerS").text("?");
      role = 'Valkriye';
    if (blind == true) {
      maxhp = 20;
         $("#guestDeck").text("\u{1F0A0}\u{1F0A0}");
      maxpw = 5;
    } else {
      break;
         $("#guestDeck").text(hexToChar(guestD[0]) + hexToChar(guestD[1]));
     case 'd':
      role = 'Wizard';
      maxhp = 15;
      maxpw = 15;
      break;
    default:
      return;
  }
  xl = 1;
  hp = maxhp;
  pw = maxpw;
  game = true;
  mapGen();
}
 
function mapGen() {
  for (var y = 0; y < mapY; y++) {
     for (var x = 0; x < mapX; x++) {
      // old mapgen
      var xborder = (y === 1 || y === mapY - 2) && (x !== 0 && x !== mapX - 1);
      var yborder = (x === 1 || x === mapX - 2) && (y !== 0 && y !== mapY - 1);
      var floor = y > 1 && y < mapY - 2 && x > 1 && x < mapX - 2;
      var up = x === 2 && y === 2;
      var down = x === mapX - 3 && y === mapY - 3;
      if (xborder || yborder) {
         base[y][x] = '#';
      } else if (up) {
        base[y][x] = '<';
      } else if (down) {
         base[y][x] = '>';
      } else if (floor) {
        base[y][x] = '.';
      }
 
      // item
      if (base[y][x] === '.' && rand.nextInt(80) === 0) {
        var items = [];
        items.push(
          (function () {
            switch (rand.nextInt(6)) {
              case 0:
                return new Item('%', 'food ration', 1);
              case 1:
                return new Item('$', 'gold piece', 25);
              case 2:
                return new Item(')', 'dagger', 1);
              case 3:
                return new Item('[', 'leather armor', 1);
              case 4:
                return new Item('?', 'scroll of upgrade', 1);
              case 5:
                return new Item('!', 'potion of healing', 1);
              default:
                return null;
            }
          })()
        );
        item[y][x] = items;
      }
 
      // entity
      if (base[y][x] === '.' && rand.nextInt(100) === 0) {
         var e = (function () {
          switch (rand.nextInt(5)) {
            case 0:
              return new Entity('B', 'bat', x, y, getHP('bat'));
            case 1:
              return new Entity('r', 'sewer rat', x, y, getHP('sewer rat'));
            case 2:
              return new Entity('k', 'kobold', x, y, getHP('kobold'));
            case 3:
              return new Entity('o', 'goblin', x, y, getHP('goblin'));
            case 4:
              return new Entity('&', 'Demogorgon', x, y, getHP('Demogorgon'));
            default:
              return null;
          }
         })();
        entities.push(e);
        entity[y][x] = e;
      }
     }
     }
  }
    var guestScore = [];
  pl = new Entity('@', name, 2, 2, hp);
    var score = pointData[hexToStr(guestD[0])] + pointData[hexToStr(guestD[1])];
  entity[2][2] = pl;
    $("#guestS").text(score);
  startGame();
     if ((pointData[hexToStr(guestD[0])] == 1 && pointData[hexToStr(guestD[1])] == 10) || (pointData[hexToStr(guestD[0])] == 10 && pointData[hexToStr(guestD[1])] == 1)) {
}
        $("#guestS").text(21);
 
        jack();
function getHP(name) {
  switch (name) {
    case 'bat':
      return 2;
     case 'sewer rat':
      return 4;
    case 'kobold':
      return 5;
    case 'goblin':
      return 8;
    case 'Demogorgon':
      return 456;
    default:
      return 1;
  }
}
 
function startGame() {
  var showInv = false;
 
  function updateStack(x, y, items) {
    item[y][x] = items;
  }
 
  function pickup() {
    var plx = pl.x;
    var ply = pl.y;
    var items = item[ply][plx];
    if (items.length > 0) {
      var i = items[0];
      inv.push(i);
      items.shift();
      updateStack(plx, ply, items);
      log.push('You picked up ' + itemName(i) + '.');
      turn();
     } else {
     } else {
      log.push('There is nothing here.');
        $("#hit").css("display", "inline-flex");
        $("#stand").css("display", "inline-flex");
        $("#surrender").css("display", "inline-flex");
    }
};
function hit() {
    $("#hit").css("display", "none");
    $("#stand").css("display", "none");
    $("#surrender").css("display", "none");
    guestD.push(cardPop());
    var guestDeq = "";
    for (i = 0; i < guestD.length; i++) {
        guestDeq += hexToChar(guestD[i]);
     }
     }
  }
     if (blind == true) {
 
        $("#guestDeck").text("\u{1F0A0}".repeat(guestDeq.length / 2));
  function ascend() {
    var plx = pl.x;
    var ply = pl.y;
     if (base[ply][plx] === '<') {
      console.log('You escaped from the dungeon.');
      process.exit(0);
     } else {
     } else {
      log.push("You can't go up here.");
        $("#guestDeck").text(guestDeq);
     }
     }
  }
    var guestScore = [];
 
    var score = 0;
  function itemName(i) {
    for (i = 0; i < guestD.length; i++) {
    return i.value + ' ' + i.name + (i.value > 1 ? 's' : '');
        guestScore.push(pointData[hexToStr(guestD[i])]);
  }
        score += guestScore[i];
 
    }
  function move(en, dx, dy) {
    $("#guestS").text(score);
     var x = en.x;
    if (score == 21 || (score == 11 && guestScore.includes(1))) {
     var y = en.y;
        $("#console").append("\n21점이므로 자동으로 스탠드를 외쳤습니다.")
     if (base[y + dy][x + dx] !== '#' && entity[y + dy][x + dx] === null) {
        stand(dealerD,guestD);
      entity[y][x] = null;
    } else if (score > 21) {
      en.x += dx;
        bust();
      en.y += dy;
    } else  {
      var floor = base[en.y][en.x];
        $("#hit").css("display", "inline-flex");
      entity[en.y][en.x] = en;
        $("#stand").css("display", "inline-flex");
      var items = item[en.y][en.x];
    }
 
    return 0;
      // log output
}
      if (en === pl) {
function stand() {
         turn();
     $("#hit").css("display", "none");
         if (floor !== '.' && floor !== '\0') {
     $("#stand").css("display", "none");
          log.push('You are standing in ' + floorDes(floor) + '.');
     $("#surrender").css("display", "none");
    var dScore = 0;
    var dealerScore = []
    for (i = 0; i < dealerD.length; i++) {
        dealerScore.push(pointData[hexToStr(dealerD[i])]);
        dScore += dealerScore[i];
    }
    while (dScore < 17) {
         dealerD.push(cardPop());
         $("#console").append("\n딜러가 카드를 뽑았습니다.")
        dealerScore = [];
        dScore = 0;
        for (i = 0; i < dealerD.length; i++) {
            dealerScore.push(pointData[hexToStr(dealerD[i])]);
            dScore += dealerScore[i];
            dealerDeq += hexToChar(dealerD[i]);
         }
         }
        if (items.length > 1) {
    }
          log.push('You see here several items.');
    var dealerDeq = "";
        } else if (items.length > 0) {
    for (i = 0; i < dealerD.length; i++) {
          var i = items[0];
            dealerDeq += hexToChar(dealerD[i]);
          log.push('You see here ' + itemName(i) + '.');
         }
         }
      }
    $("#dealerS").text(dScore);
    $("#dealerDeck").text(dealerDeq);
    guestScore = [];
    score = 0;
    for (i = 0; i < guestD.length; i++) {
        guestScore.push(pointData[hexToStr(guestD[i])]);
        score += guestScore[i];
    }
    $("#guestS").text(score);
    if (score > 21) {
        bust()
    } else if (dScore > 21) {
        $("#console").append("\n딜러의 버스트.")
        win()
    } else {
        $("#console").append("\n딜러의 스탠드.")
        compare(dealerD,guestD);
     }
     }
  }
    return 0;
 
}
  function turn() {
function compare() {
     for (var i = 0; i < entities.length; i++) {
    var dealerScore = [];
      var e = entities[i];
    var dScore = 0;
      if (e !== pl) {
     for (i = 0; i < dealerD.length; i++) {
        if (adjacent(e, pl)) {
        dealerScore.push(pointData[hexToStr(dealerD[i])]);
          attack(e, pl);
         dScore += dealerScore[i];
         } else {
          switch (rand.nextInt(8)) {
            case 0:
              move(e, -1, 0);
              break;
            case 1:
              move(e, 1, 0);
              break;
            case 2:
              move(e, 0, -1);
              break;
            case 3:
              move(e, 0, 1);
              break;
            case 4:
              move(e, -1, -1);
              break;
            case 5:
              move(e, 1, -1);
              break;
            case 6:
              move(e, -1, 1);
              break;
            case 7:
              move(e, 1, 1);
              break;
          }
        }
      }
     }
     }
     time++;
     var guestScore = [];
  }
    var score = 0;
 
    for (i = 0; i < guestD.length; i++) {
  function floorDes(c) {
        guestScore.push(pointData[hexToStr(guestD[i])]);
    switch (c) {
         score += guestScore[i];
      case '<':
        return 'staircase leading upward';
      case '>':
         return 'staircase leading downward';
      default:
        return 'nothing';
     }
     }
  }
    if (dScore < 12 && dealerScore.includes(1)) {
 
         dScore += 10
  function getAttack(s) {
    switch (s) {
      case 'bat':
      case 'goblin':
      case 'kobold':
        return 4;
      case 'sewer rat':
         return 3;
      case 'Demogorgon':
        return 48;
      default:
        return 1;
     }
     }
  }
     if (score < 12 && guestScore.includes(1)) {
 
        score += 10
  function adjacent(a, b) {
     return Math.abs(a.x - b.x) <= 1 && Math.abs(a.y - b.y) <= 1;
  }
 
  function attack(damager, damagee) {
    var dam = damager.getAttack();
    var health = damagee.health;
    if (damagee === pl) {
      log.push('The ' + damager.name + ' hits!');
      hp -= dam;
    } else if (damager === pl) {
      log.push('You hit the ' + damagee.name);
     }
     }
     if (dam >= health) {
    $("#dealerS").text(dScore);
      death(damagee);
    $("#guestS").text(score);
     if (dScore > score) {
        lose()
    } else if (dScore == score) {
        push()
     } else {
     } else {
      damagee.health -= dam;
        win()
     }
     }
  }
    return 0;
 
}
  function death(e) {
function win() {
     if (e === pl) {
     $("#console").append("\n축하합니다! 이겼습니다.")
      log.push('You were slain...');
    //$("#console").append("\n" + mult + "점을 얻었습니다.")
      refLog();
    //coins += mult;
      display();
    wincount += 1;
      process.exit(0);
    $("#deal").css("display", "inline-flex");
     } else {
    return 0;
      entities.splice(entities.indexOf(e), 1);
}
      entity[e.y][e.x] = null;
function lose() {
      log.push(e.name + ' died!');
    $("#console").append("\n졌습니다...")
    //$("#console").append("\n" + mult + "점을 잃었습니다.")
    //coins -= mult;
    losecount += 1;
    $("#deal").css("display", "inline-flex");
    publicAd();
    return 0;
}
function push() {
    $("#console").append("\n비겼습니다.")
    $("#deal").css("display", "inline-flex");
    return 0;
}
function surrender() {
    $("#hit").css("display", "none");
    $("#stand").css("display", "none");
    $("#surrender").css("display", "none");
    $("#console").append("\n이번 판을 포기하셨습니다 (패배로 처리됩니다).")
    //$("#console").append("\n" + (0.5 * mult) + "점을 잃었습니다.")
    //coins -= 0.5 * mult;
    losecount += 1;
    $("#deal").css("display", "inline-flex");
    publicAd();
     return 0;
}
function bust() {
    $("#console").append("\n버스트! 유감입니다. 졌습니다...")
    //$("#console").append("\n" + mult + "점을 잃었습니다.")
    //coins -= mult;
    losecount += 1;
    $("#hit").css("display", "none");
    $("#stand").css("display", "none");
    $("#deal").css("display", "inline-flex");
    publicAd();
    return 0;
}
function jack() {
    $("#console").append("\n블랙잭 달성! 축하합니다. 이겼습니다!")
    //$("#console").append("\n" + (1.5 * mult) + "점을 획득했습니다.")
    //coins += 1.5 * mult;
    wincount += 1;
    $("#deal").css("display", "inline-flex");
    return 0;
}
function publicAd() {
    if (coins < 0) {
        $("#notice").text("땀 흘려 번 돈이 아름답습니다.");
     }
     }
  }
     return 0;
 
}
  function display() {
function cardPop() {
     clearConsole().then(function () {
    var j, ret;
      var display = '';
    j = Math.floor(Math.random() * pcSet.length);
      for (var y = 0; y < mapY; y++) {
    ret = pcSet[j];
        for (var x = 0; x < mapX; x++) {
    pcSet.splice(j,1);
          var floor = base[y][x];
     return ret;
          var it = item[y][x];
}
          var en = entity[y][x];
          var s = ' ';
          if (floor !== '\0') {
            s = floor;
          }
          if (it.length > 0) {
            s = it[0].type;
          }
          if (en !== null) {
            s = en.type;
          }
          display += s;
        }
        display += '\n';
      }
      refLog();
      log.forEach(function (line) {
        display += line + '\n';
      });
      display +=
        name +
        ' the ' +
        role +
        ' t:' +
        time +
        '\nDlvl:' +
        dl +
        ' Lv:' +
        xl +
        ' HP:' +
        hp +
        '/' +
        maxhp +
        ' Pw:' +
        pw +
        '/' +
        maxpw +
        '\n\n';
      console.log(display);
    });
  }
 
  function inventory() {
    clearConsole().then(function () {
      var display = '';
      var c = 97;
      display += 'Your inventory:\n';
      if (inv.length === 0) {
        display += "It's empty.\n";
      } else {
        for (var i = 0; i < inv.length; i++) {
          var item = inv[i];
          display += String.fromCharCode(c) + ') ' + itemName(item) + '\n';
          c++;
        }
      }
      display += '\nType any command...\n';
      console.log(display);
      showInv = false;
     });
  }


  function askQuestion(question) {
    return new Promise(function (resolve) {
      rl.question(question, function (answer) {
        resolve(answer);
      });
    });
   }
   }


  function clearConsole() {
    return new Promise(function (resolve) {
      console.clear();
      resolve();
    });
  }
  function updateStack(x, y, items) {
    item[y][x] = items;
  }
  main();
}
}
}
}
$( plugin_uncydungeon );
$( plugin_p21 );
/* uncydungeon 끝 */
/* p21 끝 */

2023년 10월 21일 (토) 21:01 판

/** 플러그인 p21***************************
* 블랙잭
* 버전 => 0.840a4
* 작성자 : [[사용자:Riemann|Riemann]] 
* JSON => p21 = {"name":"p21","descript":"블랙잭","version":"0.840a4","local":true,"creat":"Riemann","state":"사용자:Riemann/p21","executable":true}; 
*/ 
function plugin_p21(){
  if($("[data-name='p21']").length >= 1){
		 var title = mw.config.get('wgPageName');
if (title.slice( 1, 2 ) == "라") {
    var blind = true;
    var defa = 20;
} else {
    var blind = false;
    var defa = 10;
}
var mult = defa;
$("#multiplier").text(mult);

var coins = 100;
var wincount = 0;
var losecount = 0;
//$("#console").text("스코어: " + coins + "점");
$("#console").text("스코어: " + wincount + "승 " + losecount + "패");
$("#console").append("\n블랙잭에 오신 것을 환영합니다.");

const pcLst = [
0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAD,0xAE,
0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBD,0xBE,
0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCD,0xCE,
0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDD,0xDE];
const pointData = {a1:1,a2:2,a3:3,a4:4,a5:5,a6:6,a7:7,a8:8,a9:9,aa:10,ab:10,ad:10,ae:10,b1:1,b2:2,b3:3,b4:4,b5:5,b6:6,b7:7,b8:8,b9:9,ba:10,bb:10,bd:10,be:10,c1:1,c2:2,c3:3,c4:4,c5:5,c6:6,c7:7,c8:8,c9:9,ca:10,cb:10,cd:10,ce:10,d1:1,d2:2,d3:3,d4:4,d5:5,d6:6,d7:7,d8:8,d9:9,da:10,db:10,dd:10,de:10};
var pcSet = [];
function hexToChar(x) {
    return String.fromCharCode(0xD83C) +String.fromCharCode(x + 0xDC00);
}
function hexToStr(x) {
    return x.toString(16);
}
var dealerD, guestD;
$("#deal").click(function(){
    //$("#console").text("스코어: " + coins + "점");
    $("#console").text("스코어: " + wincount + "승 " + losecount + "패");
    $("#console").append("\n새 판을 엽니다.");
    $("#deal").css("display", "none");
    $("#dealerDeck").text("");
    $("#guestDeck").text("");
    pcSet = Object.create(pcLst);
    deal();
    return 0;
});
$("#hit").click(function(){
    hit();
    return 0;
});
$("#stand").click(function(){
    stand();
    return 0;
});
$("#surrender").click(function(){
    surrender();
    return 0;
});
$("#plus").click(function(){
    inc();
    return 0;
});
$("#minus").click(function(){
    dec();
    return 0;
});
$("#reset").click(function(){
    reset();
    return 0;
});
function reset() {
    mult = defa;
    $("#multiplier").text(mult);
}

/*
function inc() {
    if (mult < 100) {
        mult += 2;
    } else {
        alert("최대 100 코인까지만 걸 수 있습니다.");
    }
    $("#multiplier").text(mult);
}

function dec() {
    if (mult > 2) {
        mult -= 2;
    } else {
        alert("설마 빚을 판돈으로 거시려고요?");
    }
    $("#multiplier").text(mult);
}
*/

function deal() {
    dealerD = [];
    guestD = [];
    dealerD.push(cardPop());
    guestD.push(cardPop());
    dealerD.push(cardPop());
    guestD.push(cardPop());
    if (blind == true) {
        $("#dealerDeck").text("\u{1F0A0}\u{1F0A0}");
    } else {
        $("#dealerDeck").text(hexToChar(dealerD[0]) + "\u{1F0A0}");
    }
    $("#dealerS").text("?");
    if (blind == true) {
        $("#guestDeck").text("\u{1F0A0}\u{1F0A0}");
    } else {
        $("#guestDeck").text(hexToChar(guestD[0]) + hexToChar(guestD[1]));
    }
    var guestScore = [];
    var score = pointData[hexToStr(guestD[0])] + pointData[hexToStr(guestD[1])];
    $("#guestS").text(score);
    if ((pointData[hexToStr(guestD[0])] == 1 && pointData[hexToStr(guestD[1])] == 10) || (pointData[hexToStr(guestD[0])] == 10 && pointData[hexToStr(guestD[1])] == 1)) {
        $("#guestS").text(21);
        jack();
    } else {
        $("#hit").css("display", "inline-flex");
        $("#stand").css("display", "inline-flex");
        $("#surrender").css("display", "inline-flex");
    }
};
function hit() {
    $("#hit").css("display", "none");
    $("#stand").css("display", "none");
    $("#surrender").css("display", "none");
    guestD.push(cardPop());
    var guestDeq = "";
    for (i = 0; i < guestD.length; i++) {
        guestDeq += hexToChar(guestD[i]);
    }
    if (blind == true) {
        $("#guestDeck").text("\u{1F0A0}".repeat(guestDeq.length / 2));
    } else {
        $("#guestDeck").text(guestDeq);
    }
    var guestScore = [];
    var score = 0;
    for (i = 0; i < guestD.length; i++) {
        guestScore.push(pointData[hexToStr(guestD[i])]);
        score += guestScore[i];
    }
    $("#guestS").text(score);
    if (score == 21 || (score == 11 && guestScore.includes(1))) {
        $("#console").append("\n21점이므로 자동으로 스탠드를 외쳤습니다.")
        stand(dealerD,guestD);
    } else if (score > 21) {
        bust();
    } else  {
        $("#hit").css("display", "inline-flex");
        $("#stand").css("display", "inline-flex");
    }
    return 0;
}
function stand() {
    $("#hit").css("display", "none");
    $("#stand").css("display", "none");
    $("#surrender").css("display", "none");
    var dScore = 0;
    var dealerScore = []
    for (i = 0; i < dealerD.length; i++) {
        dealerScore.push(pointData[hexToStr(dealerD[i])]);
        dScore += dealerScore[i];
    }
    while (dScore < 17) {
        dealerD.push(cardPop());
        $("#console").append("\n딜러가 카드를 뽑았습니다.")
        dealerScore = [];
        dScore = 0;
        for (i = 0; i < dealerD.length; i++) {
            dealerScore.push(pointData[hexToStr(dealerD[i])]);
            dScore += dealerScore[i];
            dealerDeq += hexToChar(dealerD[i]);
        }
    }
    var dealerDeq = "";
    for (i = 0; i < dealerD.length; i++) {
            dealerDeq += hexToChar(dealerD[i]);
        }
    $("#dealerS").text(dScore);
    $("#dealerDeck").text(dealerDeq);
    guestScore = [];
    score = 0;
    for (i = 0; i < guestD.length; i++) {
        guestScore.push(pointData[hexToStr(guestD[i])]);
        score += guestScore[i];
    }
    $("#guestS").text(score);
    if (score > 21) {
        bust()
    } else if (dScore > 21) {
        $("#console").append("\n딜러의 버스트.")
        win()
    } else {
        $("#console").append("\n딜러의 스탠드.")
        compare(dealerD,guestD);
    }
    return 0;
}
function compare() {
    var dealerScore = [];
    var dScore = 0;
    for (i = 0; i < dealerD.length; i++) {
        dealerScore.push(pointData[hexToStr(dealerD[i])]);
        dScore += dealerScore[i];
    }
    var guestScore = [];
    var score = 0;
    for (i = 0; i < guestD.length; i++) {
        guestScore.push(pointData[hexToStr(guestD[i])]);
        score += guestScore[i];
    }
    if (dScore < 12 && dealerScore.includes(1)) {
        dScore += 10
    }
    if (score < 12 && guestScore.includes(1)) {
        score += 10
    }
    $("#dealerS").text(dScore);
    $("#guestS").text(score);
    if (dScore > score) {
        lose()
    } else if (dScore == score) {
        push()
    } else {
        win()
    }
    return 0;
}
function win() {
    $("#console").append("\n축하합니다! 이겼습니다.")
    //$("#console").append("\n" + mult + "점을 얻었습니다.")
    //coins += mult;
    wincount += 1;
    $("#deal").css("display", "inline-flex");
    return 0;
}
function lose() {
    $("#console").append("\n졌습니다...")
    //$("#console").append("\n" + mult + "점을 잃었습니다.")
    //coins -= mult;
    losecount += 1;
    $("#deal").css("display", "inline-flex");
    publicAd();
    return 0;
}
function push() {
    $("#console").append("\n비겼습니다.")
    $("#deal").css("display", "inline-flex");
    return 0;
}
function surrender() {
    $("#hit").css("display", "none");
    $("#stand").css("display", "none");
    $("#surrender").css("display", "none");
    $("#console").append("\n이번 판을 포기하셨습니다 (패배로 처리됩니다).")
    //$("#console").append("\n" + (0.5 * mult) + "점을 잃었습니다.")
    //coins -= 0.5 * mult;
    losecount += 1;
    $("#deal").css("display", "inline-flex");
    publicAd();
    return 0;
}
function bust() {
    $("#console").append("\n버스트! 유감입니다. 졌습니다...")
    //$("#console").append("\n" + mult + "점을 잃었습니다.")
    //coins -= mult;
    losecount += 1;
    $("#hit").css("display", "none");
    $("#stand").css("display", "none");
    $("#deal").css("display", "inline-flex");
    publicAd();
    return 0;
}
function jack() {
    $("#console").append("\n블랙잭 달성! 축하합니다. 이겼습니다!")
    //$("#console").append("\n" + (1.5 * mult) + "점을 획득했습니다.")
    //coins += 1.5 * mult;
    wincount += 1;
    $("#deal").css("display", "inline-flex");
    return 0;
}
function publicAd() {
    if (coins < 0) {
        $("#notice").text("땀 흘려 번 돈이 아름답습니다.");
    }
    return 0;
}
function cardPop() {
    var j, ret;
    j = Math.floor(Math.random() * pcSet.length);
    ret = pcSet[j];
    pcSet.splice(j,1);
    return ret;
}

		
  }

}
$( plugin_p21 );
/* p21 끝 */