game.js初步拆分和模块化

This commit is contained in:
shijian 2023-12-20 09:27:46 +08:00
parent 89fa4c7f37
commit 8853fd733a
379 changed files with 55582 additions and 119861 deletions

64049
game/game.js

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,13 @@
import { ai } from './noname/ai.js'; import { GNC as gnc } from './noname/gnc/index.js';
import { Game as game } from './noname/game.js'; import { AI as ai } from './noname/ai/index.js';
import { Get as get } from './noname/get.js'; import { Game as game } from './noname/game/index.js';
import { Library as lib } from './noname/library.js'; import { Get as get } from './noname/get/index.js';
import { status as _status } from './noname/status.js'; import { Library as lib } from './noname/library/index.js';
import { UI as ui } from './noname/ui.js'; import { status as _status } from './noname/status/index.js';
import { UI as ui } from './noname/ui/index.js';
export { export {
gnc,
ai, ai,
game, game,
get, get,

View File

@ -1,7 +0,0 @@
import { Basic } from "./ai/basic.js";
import { Get } from "./get.js";
export const ai = {
basic: Basic,
get: Get
};

View File

@ -1,32 +1,30 @@
import { Game } from "../game.js"; import { Get as get } from '../get/index.js';
import { Get } from "../get.js"; import { Game as game } from '../game/index.js';
import { status } from "../status.js"; import { status as _status } from '../status/index.js';
import { Click } from "../ui/click.js"; import { UI as ui } from '../ui/index.js';
import { selected } from "../ui/selected.js"; import { Library as lib } from '../library/index.js';
import { GNC as gnc } from '../gnc/index.js';
export class Basic { import { Uninstantable } from "../util/index.js";
constructor() {
throw new TypeError(`${new.target.name} is not a constructor`);
}
export class Basic extends Uninstantable {
static chooseButton(check) { static chooseButton(check) {
var event = status.event; var event = _status.event;
var i, j, range, buttons, buttons2; var i, j, range, buttons, buttons2;
var ok = false, forced = event.forced; var ok = false, forced = event.forced;
var iwhile = 100; var iwhile = 100;
while (iwhile--) { while (iwhile--) {
range = Get.select(event.selectButton); range = get.select(event.selectButton);
if (selected.buttons.length >= range[0]) { if (ui.selected.buttons.length >= range[0]) {
ok = true; ok = true;
} }
if (range[1] <= -1) { if (range[1] <= -1) {
j = 0; j = 0;
for (i = 0; i < selected.buttons.length; i++) { for (i = 0; i < ui.selected.buttons.length; i++) {
j += check(selected.buttons[i]); j += check(ui.selected.buttons[i]);
} }
return (j > 0); return (j > 0);
} }
buttons = Get.selectableButtons(); buttons = get.selectableButtons();
if (buttons.length == 0) { if (buttons.length == 0) {
return ok; return ok;
} }
@ -49,41 +47,40 @@ export class Basic {
} }
} }
buttons[ix].classList.add('selected'); buttons[ix].classList.add('selected');
selected.buttons.add(buttons[ix]); ui.selected.buttons.add(buttons[ix]);
Game.check(); game.check();
if (selected.buttons.length >= range[0]) { if (ui.selected.buttons.length >= range[0]) {
ok = true; ok = true;
} }
if (selected.buttons.length == range[1]) { if (ui.selected.buttons.length == range[1]) {
return true; return true;
} }
} }
} }
static chooseCard(check) { static chooseCard(check) {
var event = status.event; var event = _status.event;
if (event.filterCard == undefined) return (check() > 0); if (event.filterCard == undefined) return (check() > 0);
var i, j, range, cards, cards2, skills, check, effect; var i, j, range, cards, cards2, skills, check, effect;
var ok = false, forced = event.forced; var ok = false, forced = event.forced;
var iwhile = 100; var iwhile = 100;
while (iwhile--) { while (iwhile--) {
range = Get.select(event.selectCard); range = get.select(event.selectCard);
if (selected.cards.length >= range[0]) { if (ui.selected.cards.length >= range[0]) {
ok = true; ok = true;
} }
if (range[1] <= -1) { if (range[1] <= -1) {
if (selected.cards.length == 0) return true; if (ui.selected.cards.length == 0) return true;
j = 0; j = 0;
for (i = 0; i < selected.cards.length; i++) { for (i = 0; i < ui.selected.cards.length; i++) {
effect = check(selected.cards[i]); effect = check(ui.selected.cards[i]);
if (effect < 0) j -= Math.sqrt(-effect); if (effect < 0) j -= Math.sqrt(-effect);
else j += Math.sqrt(effect); else j += Math.sqrt(effect);
} }
return (j > 0); return (j > 0);
} }
cards = Get.selectableCards(); cards = get.selectableCards();
if (!status.event.player._noSkill) { if (!_status.event.player._noSkill) {
cards = cards.concat(Get.skills()); cards = cards.concat(get.skills());
} }
if (cards.length == 0) { if (cards.length == 0) {
return ok; return ok;
@ -107,11 +104,11 @@ export class Basic {
} }
} }
if (typeof cards[ix] == 'string') { if (typeof cards[ix] == 'string') {
Click.skill(cards[ix]); ui.click.skill(cards[ix]);
var info = Get.info(event.skill); var info = get.info(event.skill);
if (info.filterCard) { if (info.filterCard) {
check = info.check || Get.unuseful2; check = info.check || get.unuseful2;
return (this.chooseCard(check)); return (ai.basic.chooseCard(check));
} }
else { else {
return true; return true;
@ -119,33 +116,32 @@ export class Basic {
} }
else { else {
cards[ix].classList.add('selected'); cards[ix].classList.add('selected');
selected.cards.add(cards[ix]); ui.selected.cards.add(cards[ix]);
Game.check(); game.check();
if (selected.cards.length >= range[0]) { if (ui.selected.cards.length >= range[0]) {
ok = true; ok = true;
} }
if (selected.cards.length == range[1]) { if (ui.selected.cards.length == range[1]) {
return true; return true;
} }
} }
} }
} }
static chooseTarget(check) { static chooseTarget(check) {
var event = status.event; var event = _status.event;
if (event.filterTarget == undefined) return (check() > 0); if (event.filterTarget == undefined) return (check() > 0);
var i, j, range, targets, targets2, effect; var i, j, range, targets, targets2, effect;
var ok = false, forced = event.forced; var ok = false, forced = event.forced;
var iwhile = 100; var iwhile = 100;
while (iwhile--) { while (iwhile--) {
range = Get.select(event.selectTarget); range = get.select(event.selectTarget);
if (selected.targets.length >= range[0]) { if (ui.selected.targets.length >= range[0]) {
ok = true; ok = true;
} }
if (range[1] <= -1) { if (range[1] <= -1) {
j = 0; j = 0;
for (i = 0; i < selected.targets.length; i++) { for (i = 0; i < ui.selected.targets.length; i++) {
effect = check(selected.targets[i]); effect = check(ui.selected.targets[i]);
if (effect < 0) j -= Math.sqrt(-effect); if (effect < 0) j -= Math.sqrt(-effect);
else j += Math.sqrt(effect); else j += Math.sqrt(effect);
} }
@ -154,7 +150,7 @@ export class Basic {
else if (range[1] == 0) { else if (range[1] == 0) {
return check() > 0 return check() > 0
} }
targets = Get.selectableTargets(); targets = get.selectableTargets();
if (targets.length == 0) { if (targets.length == 0) {
return range[0] == 0 || ok; return range[0] == 0 || ok;
} }
@ -177,14 +173,21 @@ export class Basic {
} }
} }
targets[ix].classList.add('selected'); targets[ix].classList.add('selected');
selected.targets.add(targets[ix]); ui.selected.targets.add(targets[ix]);
Game.check(); game.check();
if (selected.targets.length >= range[0]) { if (ui.selected.targets.length >= range[0]) {
ok = true; ok = true;
} }
if (selected.targets.length == range[1]) { if (ui.selected.targets.length == range[1]) {
return true; return true;
} }
} }
} }
} }
export class AI extends Uninstantable {
static basic = Basic;
static get = get;
};
export const ai = AI;

View File

@ -1,7 +0,0 @@
import { Player } from "../library/element/player.js";
interface AI extends Record<string, any> {
customAttitude: ((from: Player, to: Player) => number)[];
}
export const ai: AI;

View File

@ -1,3 +0,0 @@
export const ai = {
customAttitude: []
};

View File

@ -1,4 +0,0 @@
interface CardTag extends Record<string, `${number}`[]> {
}
export const cardTag: CardTag;

View File

@ -1,7 +0,0 @@
export const cardTag = {
yingbian_zhuzhan: [],
yingbian_kongchao: [],
yingbian_fujia: [],
yingbian_canqu: [],
yingbian_force: []
};

View File

@ -1,9 +0,0 @@
import { GameEvent } from "../library/element/game-event";
export interface GlobalHistory {
cardMove: GameEvent[];
custom: unknown[];
useCard: GameEvent[];
changeHp: GameEvent[];
everything: GameEvent[];
}

View File

@ -1 +0,0 @@
export const postReconnect = {};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,378 +0,0 @@
export class Is {
constructor() {
throw new TypeError(`${new.target.name} is not a constructor`);
}
/**
* 判断是否为进攻坐骑
* @param {Card | VCard} card
* @param {false | Player} [player]
* @returns {boolean}
*/
static attackingMount(card, player) {
const subtype = get.subtype(card, player);
if (subtype == "equip4") return true;
else if (subtype == "equip6") {
const info = get.info(card, player), distance = info.distance;
if (!distance) return false;
if (distance.globalFrom && !info.notMount) return true;
}
return false;
}
/**
* 判断是否为防御坐骑
* @param {Card | VCard} card
* @param {false | Player} [player]
* @returns {boolean}
*/
static defendingMount(card, player) {
const subtype = get.subtype(card, player);
if (subtype == "equip3") return true;
else if (subtype == "equip6") {
const info = get.info(card, player), distance = info.distance;
if (!distance) return false;
if (distance.globalTo && !info.notMount) return true;
}
return false;
}
/**
* 判断坐骑栏是否被合并
*/
static mountCombined() {
if (lib.configOL) {
return lib.configOL.mount_combine;
}
else if (typeof _status.mountCombined != "boolean") {
_status.mountCombined = lib.config.mount_combine;
}
return _status.mountCombined;
}
/**
* 判断传入的参数的属性是否相同参数可以为卡牌卡牌信息属性等
* @param {...} infos 要判断的属性列表
* @param {boolean} every 是否判断每一个传入的属性是否完全相同而不是存在部分相同
*/
static sameNature() {
let processedArguments = [], every = false;
Array.from(arguments).forEach(argument => {
if (typeof argument == "boolean") every = argument;
else if (argument) processedArguments.push(argument);
});
if (!processedArguments.length) return true;
if (processedArguments.length == 1) {
const argument = processedArguments[0];
if (!Array.isArray(argument)) return false;
if (!argument.length) return true;
if (argument.length == 1) return false;
processedArguments = argument;
}
const naturesList = processedArguments.map(card => {
if (typeof card == "string") return card.split(lib.natureSeparator);
else if (Array.isArray(card)) return card;
return get.natureList(card || {});
});
const testingNaturesList = naturesList.slice(0, naturesList.length - 1);
if (every) return testingNaturesList.every((natures, index) => naturesList.slice(index + 1).every(testingNatures => testingNatures.length == natures.length && testingNatures.every(nature => natures.includes(nature))));
return testingNaturesList.every((natures, index) => {
const comparingNaturesList = naturesList.slice(index + 1);
if (natures.length) return natures.some(nature => comparingNaturesList.every(testingNatures => testingNatures.includes(nature)));
return comparingNaturesList.every(testingNatures => !testingNatures.length);
});
}
/**
* 判断传入的参数的属性是否不同参数可以为卡牌卡牌信息属性等
* @param ...infos 要判断的属性列表
* @param every {boolean} 是否判断每一个传入的属性是否完全不同而不是存在部分不同
*/
static differentNature() {
let processedArguments = [], every = false;
Array.from(arguments).forEach(argument => {
if (typeof argument == "boolean") every = argument;
else if (argument) processedArguments.push(argument);
});
if (!processedArguments.length) return false;
if (processedArguments.length == 1) {
const argument = processedArguments[0];
if (!Array.isArray(argument)) return true;
if (!argument.length) return false;
if (argument.length == 1) return true;
processedArguments = argument;
}
const naturesList = processedArguments.map(card => {
if (typeof card == "string") return card.split(lib.natureSeparator);
else if (Array.isArray(card)) return card;
return get.natureList(card || {});
});
const testingNaturesList = naturesList.slice(0, naturesList.length - 1);
if (every) return testingNaturesList.every((natures, index) => naturesList.slice(index + 1).every(testingNatures => testingNatures.every(nature => !natures.includes(nature))));
return testingNaturesList.every((natures, index) => {
const comparingNaturesList = naturesList.slice(index + 1);
if (natures.length) return natures.some(nature => comparingNaturesList.every(testingNatures => !testingNatures.length || testingNatures.some(testingNature => testingNature != nature)));
return comparingNaturesList.every(testingNatures => testingNatures.length);
});
}
/**
* 判断一张牌是否为明置手牌
*/
static shownCard(card) {
if (!card) return false;
const gaintag = card.gaintag;
return Array.isArray(gaintag) && gaintag.some(tag => tag.startsWith("visible_"));
}
/**
* 是否是虚拟牌
*/
static vituralCard(card) {
return card.isCard || (!("cards" in card) || !Array.isArray(card.cards) || card.cards.length == 0);
}
/**
* 是否是转化牌
*/
static convertedCard(card) {
return !card.isCard && ("cards" in card) && Array.isArray(card.cards) && card.cards.length > 0;
}
/**
* 是否是实体牌
*/
static ordinaryCard(card) {
return card.isCard && ("cards" in card) && Array.isArray(card.cards) && card.cards.length == 1;
}
/**
* 押韵判断
*/
static yayun(str1, str2) {
if (str1 == str2) return true;
var pinyin1 = get.pinyin(str1, false), pinyin2 = get.pinyin(str2, false);
if (!pinyin1.length || !pinyin2.length) return false;
var pron1 = pinyin1[pinyin1.length - 1], pron2 = pinyin2[pinyin2.length - 1];
if (pron1 == pron2) return true;
return get.yunjiao(pron1) == get.yunjiao(pron2);
}
static blocked(skill, player) {
if (!player.storage.skill_blocker || !player.storage.skill_blocker.length) return false;
for (var i of player.storage.skill_blocker) {
if (lib.skill[i] && lib.skill[i].skillBlocker && lib.skill[i].skillBlocker(skill, player)) return true;
}
return false;
}
static double(name, array) {
const extraInformations = get.character(name, 4);
if (!extraInformations) return false;
for (const extraInformation of extraInformations) {
if (!extraInformation.startsWith("doublegroup:")) continue;
return array ? extraInformation.split(":").slice(1) : true;
}
return false;
}
/**
* Check if the card has a Yingbian condition
*
* 检测此牌是否具有应变条件
*/
static yingbianConditional(card) {
return get.is.complexlyYingbianConditional(card) || get.is.simplyYingbianConditional(card);
}
static complexlyYingbianConditional(card) {
for (const key of lib.yingbian.condition.complex.keys()) {
if (get.cardtag(card, `yingbian_${key}`)) return true;
}
return false;
}
static simplyYingbianConditional(card) {
for (const key of lib.yingbian.condition.simple.keys()) {
if (get.cardtag(card, `yingbian_${key}`)) return true;
}
return false;
}
/**
* Check if the card has a Yingbian effect
*
* 检测此牌是否具有应变效果
*/
static yingbianEffective(card) {
for (const key of lib.yingbian.effect.keys()) {
if (get.cardtag(card, `yingbian_${key}`)) return true;
}
return false;
}
static yingbian(card) {
return get.is.yingbianConditional(card) || get.is.yingbianEffective(card);
}
static emoji(substring) {
if (substring) {
var reg = new RegExp("[~#^$@%&!?%*]", "g");
if (substring.match(reg)) {
return true;
}
for (var i = 0; i < substring.length; i++) {
var hs = substring.charCodeAt(i);
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
var ls = substring.charCodeAt(i + 1);
var uc = ((hs - 0xd800) * 0x400) + (ls - 0xdc00) + 0x10000;
if (0x1d000 <= uc && uc <= 0x1f77f) {
return true;
}
}
}
else if (substring.length > 1) {
var ls = substring.charCodeAt(i + 1);
if (ls == 0x20e3) {
return true;
}
}
else {
if (0x2100 <= hs && hs <= 0x27ff) {
return true;
}
else if (0x2B05 <= hs && hs <= 0x2b07) {
return true;
}
else if (0x2934 <= hs && hs <= 0x2935) {
return true;
}
else if (0x3297 <= hs && hs <= 0x3299) {
return true;
}
else if (hs == 0xa9 || hs == 0xae || hs == 0x303d || hs == 0x3030
|| hs == 0x2b55 || hs == 0x2b1c || hs == 0x2b1b
|| hs == 0x2b50) {
return true;
}
}
}
}
return false;
}
static banWords(str) {
return get.is.emoji(str) || window.bannedKeyWords.some(item => str.includes(item));
}
static converted(event) {
return !(event.card && event.card.isCard);
}
static safari() {
return userAgent.indexOf("safari" != -1) && userAgent.indexOf("chrome") == -1;
}
static freePosition(cards) {
return !cards.some(card => !card.hasPosition || card.hasPosition());
}
static nomenu(name, item) {
var menus = ["system", "menu"];
var configs = {
show_round_menu: lib.config.show_round_menu,
round_menu_func: lib.config.round_menu_func,
touchscreen: lib.config.touchscreen,
swipe_up: lib.config.swipe_up,
swipe_down: lib.config.swipe_down,
swipe_left: lib.config.swipe_left,
swipe_right: lib.config.swipe_right,
right_click: lib.config.right_click,
phonelayout: lib.config.phonelayout
};
configs[name] = item;
if (!configs.phonelayout) return false;
if (configs.show_round_menu && menus.contains(configs.round_menu_func)) {
return false;
}
if (configs.touchscreen) {
if (menus.contains(configs.swipe_up)) return false;
if (menus.contains(configs.swipe_down)) return false;
if (menus.contains(configs.swipe_left)) return false;
if (menus.contains(configs.swipe_right)) return false;
}
else {
if (configs.right_click == "config") return false;
}
if (name) {
setTimeout(function () {
alert("请将至少一个操作绑定为显示按钮或打开菜单,否则将永远无法打开菜单");
});
}
return true;
}
static altered() {
return false;
}
static node(obj) {
var str = Object.prototype.toString.call(obj);
if (str && str.indexOf("[object HTML")) return true;
return false;
}
static div(obj) {
return Object.prototype.toString.call(obj) === "[object HTMLDivElement]";
}
static map(obj) {
return Object.prototype.toString.call(obj) === "[object Map]";
}
static set(obj) {
return Object.prototype.toString.call(obj) === "[object Set]";
}
static object(obj) {
return Object.prototype.toString.call(obj) === "[object Object]";
}
static singleSelect(func) {
if (typeof func == "function") return false;
var select = get.select(func);
return select[0] == 1 && select[1] == 1;
}
static jun(name) {
if (get.mode() == "guozhan") {
if (name && typeof name == "object") {
if (name.isUnseen && name.isUnseen(0)) return false;
name = name.name1;
}
if (typeof name == "string" && name.startsWith("gz_jun_")) {
return true;
}
}
return false;
}
static versus() {
return !_status.connectMode && get.mode() == "versus" && _status.mode == "three";
}
static changban() {
return get.mode() == "single" && _status.mode == "changban";
}
static single() {
return get.mode() == "single" && _status.mode == "normal";
}
static mobileMe(player) {
return (game.layout == "mobile" || game.layout == "long") && !game.chess && player.dataset.position == 0;
}
static newLayout() {
return game.layout != "default";
}
static phoneLayout() {
if (!lib.config.phonelayout) return false;
return (game.layout == "mobile" || game.layout == "long" || game.layout == "long2" || game.layout == "nova");
}
static singleHandcard() {
return game.singleHandcard || game.layout == "mobile" || game.layout == "long" || game.layout == "long2" || game.layout == "nova";
}
static linked2(player) {
if (game.chess) return true;
if (lib.config.link_style2 != "rotate") return true;
// if(game.chess) return false;
if (game.layout == "long" || game.layout == "long2" || game.layout == "nova") return true;
if (player.dataset.position == "0") {
return ui.arena.classList.contains("oblongcard");
}
return false;
}
static empty(obj) {
return Object.keys(obj).length == 0;
}
static pos(str) {
return str == "h" || str == "e" || str == "j" || str == "he" || str == "hj" || str == "ej" || str == "hej";
}
static locked(skill, player) {
var info = lib.skill[skill];
if (typeof info.locked == "function") return info.locked(skill, player);
if (info.locked == false) return false;
if (info.trigger && info.forced) return true;
if (info.mod) return true;
if (info.locked) return true;
return false;
}
}

View File

@ -1,13 +1,21 @@
const GeneratorFunction = (function* () { import { GeneratorFunction, Uninstantable } from "../util/index.js";
}).constructor;
export class GNC { class Is extends Uninstantable {
constructor() { static coroutine(item) {
throw new TypeError(`${new.target.name} is not a constructor`); return typeof item == "function" && item.name == "genCoroutine";
} }
static generatorFunc(item) {
return item instanceof GeneratorFunction;
}
static generator(item) {
return (typeof item == "object") && ("constructor" in item) && item.constructor && ("constructor" in item.constructor) && item.constructor.constructor === GeneratorFunction;
}
};
// gnc: GeNCoroutine
export class GNC extends Uninstantable {
static of(fn) { static of(fn) {
return this.isGeneratorFunc(fn) ? function genCoroutine() { return gnc.is.generatorFunc(fn) ? function genCoroutine() {
let gen = fn.apply(this, arguments); let gen = fn.apply(this, arguments);
gen.status = "next"; gen.status = "next";
gen.state = undefined; gen.state = undefined;
@ -37,21 +45,9 @@ export class GNC {
Promise.resolve(result).then(nexts, throws); Promise.resolve(result).then(nexts, throws);
} }
return new Promise(callback); return new Promise(callback);
} : (() => { throw new TypeError("gnc.of needs a GeneratorFunction.") })(); } : (() => { throw new TypeError("gnc.of needs a GeneratorFunction.") })()
} }
static is = Is;
};
static isCoroutine(item) { export const gnc = GNC;
return typeof item == "function" && item.name == "genCoroutine";
}
/**
* @returns {item is GeneratorFunction}
*/
static isGeneratorFunc(item) {
return item instanceof GeneratorFunction;
}
static isGenerator(item) {
return typeof item == "object" && "constructor" in item && item.constructor && "constructor" in item.constructor && item.constructor.constructor === GeneratorFunction;
}
}

View File

@ -1 +0,0 @@
export { Library as InternalLibrary } from "./library.js";

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
import { card } from "./animate/card.js";
import { skill } from "./animate/skill.js";
export const animate = {
skill,
card
};

View File

@ -1,4 +0,0 @@
interface Card extends Record<string, Function> {
}
export const card: Card;

View File

@ -1 +0,0 @@
export const card = {};

View File

@ -1,4 +0,0 @@
interface Skill extends Record<string, Function> {
}
export const skill: Skill;

View File

@ -1 +0,0 @@
export const skill = {};

View File

@ -1,101 +0,0 @@
/**
* **无名杀消息推送库**
*
* 通过`EventTarget`机制实现消息推送和接收的解耦
* 从而使消息接收方无需依赖发布方发布方也无需考虑接收方
*
* > `lib.announce`不是`actor`模型若不存在订阅者则消息发送将无意义
*
* @example
* // 甲扩展(如《千幻聆音》)在角色皮肤切换后,调用:
* lib.announce.publish("skinChange", {
* player,
* playerName: "zhangfei",
* originSkin: "image/xxx.jpg",
* currentSkin: "image/yyy.jpg"
* });
*
* // 乙扩展监听此`skinChange`事件,并修改自己扩展相关界面的图片:
* const method = lib.announce.subscribe("skinChange", (e) => {
* div.setBackgroundImage(e.currentSkin);
* });
*
* // 若此时乙扩展不想继续订阅`skinChange`事件,可以通过`unsubscribe`解除订阅
* lib.announce.unsubscribe("skinChange", method);
*/
export const announce = {
_announce: document.createElement("Announce"),
/**
* @type {Map<(values: T) => void, Map<string, (event: Event) => void>>}
*/
_announce_cache: new Map(),
/**
* 推送任意数据给所有监听了指定事件的订阅者并返回给定的数据
*
* 若不存在订阅指定事件的订阅者则推送的数据将无意义
*
* @template T
* @param {string} name - 要推送事件的名称
* @param {T} values - 要推送的数据
* @returns {T}
*/
publish(name, values) {
if (this._announce) this._announce.dispatchEvent(new CustomEvent(name, {
detail: values
}));
return values;
},
/**
* 订阅给定名字的事件并返回给定的函数
*
* 在事件触发时执行给定的函数
*
* 给定的函数将被存储至当前实例中用于取消订阅时获取
*
* @template T
* @param {string} name - 要订阅事件的名称
* @param {(values: T) => void} method - 事件触发时执行的函数
* @returns {(values: T) => void}
*/
subscribe(name, method) {
if (this._announce && this._announce_cache) {
let subscribeFunction;
if (this._announce_cache.has(method)) {
let records = this._announce_cache.get(method);
subscribeFunction = records.get("Listener");
records.get("EventTargets").add(name);
}
else {
subscribeFunction = event => method(event.detail);
let records = new Map();
records.set("Listener", subscribeFunction);
records.set("EventTargets", [name]);
this._announce_cache.set(method, records);
}
this._announce.addEventListener(name, subscribeFunction);
}
return method;
},
/**
* 取消指定事件某一函数的订阅并返回该函数
*
* 给定的函数将不再于事件触发时执行其余同事件需触发的函数不受限制
*
* @template T
* @param {string} name - 要取消订阅事件的名称
* @param {(values: T) => void} method - 订阅指定事件的函数
* @returns {(values: T) => void}
*/
unsubscribe(name, method) {
if (this._announce && this._announce_cache && this._announce_cache.has(method)) {
let records = this._announce_cache.get(method);
const listener = records.get("Listener");
let eventTargets = records.get("EventTargets");
eventTargets.remove(name);
if (eventTargets.length <= 0) this._announce_cache.remove(method);
this._announce.removeEventListener(name, listener);
}
return method;
}
};

View File

@ -1,4 +0,0 @@
interface CardPack extends Record<string, string[]> {
}
export const cardPack: CardPack;

View File

@ -1 +0,0 @@
export const cardPack = {};

View File

@ -1 +0,0 @@
export const cardPile = {};

View File

@ -1,4 +0,0 @@
interface CardType extends Record<string, number> {
}
export const cardType: CardType;

View File

@ -1 +0,0 @@
export const cardType = {};

View File

@ -1,93 +0,0 @@
export const card = {
list: [],
cooperation_damage: {
fullskin: true
},
cooperation_draw: {
fullskin: true,
cardimage: "cooperation_damage"
},
cooperation_discard: {
fullskin: true,
cardimage: "cooperation_damage"
},
cooperation_use: {
fullskin: true,
cardimage: "cooperation_damage"
},
pss_paper: {
type: "pss",
fullskin: true
},
pss_scissor: {
type: "pss",
fullskin: true,
},
pss_stone: {
type: "pss",
fullskin: true
},
feichu_equip1: {
type: "equip",
subtype: "equip1"
},
feichu_equip2: {
type: "equip",
subtype: "equip2"
},
feichu_equip3: {
type: "equip",
subtype: "equip3"
},
feichu_equip4: {
type: "equip",
subtype: "equip4"
},
feichu_equip5: {
type: "equip",
subtype: "equip5"
},
feichu_equip6: {
type: "equip",
subtype: "equip6"
},
zhengsu_leijin: {},
zhengsu_mingzhi: {},
zhengsu_bianzhen: {},
disable_judge: {},
group_wei: {
fullskin: true
},
group_shu: {
fullskin: true
},
group_wu: {
fullskin: true
},
group_qun: {
fullskin: true
},
group_key: {
fullskin: true
},
group_jin: {
fullskin: true
},
db_atk1: {
type: "db_atk",
fullimage: true
},
db_atk2: {
type: "db_atk",
fullimage: true
},
db_def1: {
type: "db_def",
fullimage: true
},
db_def2: {
type: "db_def",
fullimage: true
}
};

View File

@ -1,98 +0,0 @@
/**
* **无名杀频道推送机制**
*
* 鉴于`Javascript`的特性及自身对所需功能的思考这是一个参考`Golang``channel`设计的完全和`go channel`不一样的异步消息传递对象
*
* 当且仅当接收方和发送方均存在时进行消息传递完全保证信息传递的单一性发送方/接收方一旦确定则无法更改和准确性发送方必然将消息发送给接收方
*
* 若存在发送方/接收方时调用`send`/`receive`将报错
*
* 若需要异步/不报错发送信息请等待`lib.actor`
*
* @template T
* @example
* // 创建一个频道
* const channel = new lib.channel();
*
* // 从某个角落接收channel发出的消息若无消息则等待
* const message = await channel.receive();
*
* // 从某个角落向channel发消息若无消息接收则等待
* await channel.send(item);
*/
export class Channel {
constructor() {
/**
* @type {"active" | "receiving" | "sending"}
*/
this.status = "active";
/**
* @type {import("./promise-resolve").PromiseResolve<T> | [T, import("./promise-resolve").PromiseResolve<void>] | null}
*/
this._buffer = null;
}
/**
* 向该频道发送消息在消息未被接受前将等待
*
* @param {T} value - 要发送的消息
* @returns {Promise<void>}
*/
send(value) {
return new Promise((resolve, reject) => {
switch (this.status) {
case "sending":
// TODO: handle the error.
reject(new Error());
break;
case "receiving": {
/**
* @type {import("./promise-resolve").PromiseResolve<T>}
*/
const buffer = this._buffer;
this._buffer = null;
buffer(value);
this.status = "active";
resolve();
break;
}
case "active":
this.status = "sending";
this._buffer = [value, resolve];
break;
}
});
}
/**
* 接收频道所发送的消息若无消息发送则等待
*
* @returns {Promise<T>} 接收到的消息
*/
receive() {
return new Promise((resolve, reject) => {
switch (this.status) {
case "receiving":
// TODO: handle the error.
reject(new Error());
break;
case "sending": {
/**
* @type {[T, import("./promise-resolve").PromiseResolve<void>]}
*/
const buffer = this._buffer;
this._buffer = null;
resolve(buffer[0]);
this.status = "active";
buffer[1]();
break;
}
case "active":
this.status = "receiving";
this._buffer = resolve;
break;
}
});
}
}

View File

@ -1,17 +0,0 @@
import { Get } from "../get.js";
import { configuration } from "./configuration.js";
export class CharacterDialogGroup {
constructor() {
throw new TypeError(`${new.target.name} is not a constructor`);
}
static 收藏(name, capt) {
return configuration.favouriteCharacter.includes(name) ? capt : null;
}
static 最近(name, capt) {
var list = Get.config("recentCharacter") || [];
return list.includes(name) ? capt : null;
}
}

View File

@ -1,4 +0,0 @@
interface CharacterFilter extends Record<string, (mode: string) => boolean> {
}
export const characterFilter: CharacterFilter;

View File

@ -1 +0,0 @@
export const characterFilter = {};

View File

@ -1,4 +0,0 @@
type CharacterSex = "double" | "female" | "male" | "none" | "unknown" | string & {};
type CharacterGroup = "wei" | "shu" | "wu" | "qun" | "jin";
type CharacterHP = number | `${number}/${number}` | `${number}/${number}/${number}`;
export type CharacterInformation = [CharacterSex, CharacterGroup, CharacterHP, string[], string[]?];

View File

@ -1,4 +0,0 @@
interface CharacterIntro extends Record<string, string> {
}
export const characterIntro: CharacterIntro;

View File

@ -1 +0,0 @@
export const characterIntro = {};

View File

@ -1,6 +0,0 @@
import { CharacterInformation } from "./character-information.js";
interface CharacterPack extends Record<string, Record<string, CharacterInformation>> {
}
export const characterPack: CharacterPack;

View File

@ -1 +0,0 @@
export const characterPack = {};

View File

@ -1,4 +0,0 @@
interface CharacterReplace extends Record<string, string[]> {
}
export const characterReplace: CharacterReplace;

View File

@ -1 +0,0 @@
export const characterReplace = {};

View File

@ -1,4 +0,0 @@
interface CharacterSort extends Record<string, Record<string, string[]>> {
}
export const characterSort: CharacterSort;

View File

@ -1 +0,0 @@
export const characterSort = {};

View File

@ -1,4 +0,0 @@
interface CharacterTitle extends Record<string, string> {
}
export const characterTitle: CharacterTitle;

View File

@ -1 +0,0 @@
export const characterTitle = {};

View File

@ -1 +0,0 @@
export const character = {};

View File

@ -1,693 +0,0 @@
export class Cheat {
constructor() {
throw new TypeError(`${new.target.name} is not a constructor`);
}
static i() {
window.cheat = lib.cheat;
window.game = game;
window.ui = ui;
window.get = get;
window.ai = ai;
window.lib = lib;
window._status = _status;
}
static dy() {
var next = game.me.next;
for (var i = 0; i < 10; i++) {
if (next.identity != "zhu") {
break;
}
next = next.next;
}
next.die();
}
static x() {
var gl = function (dir, callback) {
var files = [], folders = [];
dir = "/Users/widget/Documents/extension/" + dir;
lib.node.fs.readdir(dir, function (err, filelist) {
for (var i = 0; i < filelist.length; i++) {
if (filelist[i][0] != "." && filelist[i][0] != "_") {
if (lib.node.fs.statSync(dir + "/" + filelist[i]).isDirectory()) {
folders.push(filelist[i]);
}
else {
files.push(filelist[i]);
}
}
}
callback(folders, files);
});
}
var args = Array.from(arguments);
for (var i = 0; i < args.length; i++) {
args[i] = args[i][0];
}
gl("", function (list) {
if (args.length) {
for (var i = 0; i < list.length; i++) {
if (!args.contains(list[i][0])) {
list.splice(i--, 1);
}
}
}
if (list.length) {
for (var i = 0; i < list.length; i++) {
(function (str) {
gl(str, function (folders, files) {
if (files.length > 1) {
for (var i = 0; i < files.length; i++) {
if (files[i].includes("extension.js")) {
files.splice(i--, 1);
}
else {
if (i % 5 == 0) {
str += "\n\t\t\t";
}
str += `"${files[i]}",`;
}
}
console.log(str.slice(0, str.length - 1));
}
});
}(list[i]));
}
}
});
}
static cfg() {
var mode = lib.config.all.mode.slice(0);
mode.remove("connect");
mode.remove("brawl");
var banned = ["shen_guanyu", "shen_caocao", "caopi", "re_daqiao", "caorui",
"daqiao", "lingcao", "liuzan", "lusu", "luxun", "yanwen", "zhouyu", "ns_wangyue", "gw_yenaifa",
"old_caozhen", "swd_jiangziya", "xuhuang", "maliang", "guojia", "simayi", "swd_kangnalishi", "hs_siwangzhiyi", "hs_nozdormu", "old_zhuzhi"];
var bannedcards = ["zengbin"];
var favs = ["hs_tuoqi", "hs_siwangxianzhi", "hs_xukongzhiying", "hs_hsjiasha", "gjqt_xieyi", "gjqt_yunwuyue", "gjqt_beiluo",
"gjqt_cenying", "shen_lvmeng", "shen_zhaoyun", "shen_zhugeliang", "ow_ana", "chenlin", "ns_guanlu", "hs_guldan", "swd_guyue",
"pal_jiangyunfan", "mtg_jiesi", "swd_lanyin", "pal_liumengli", "swd_muyun", "pal_nangonghuang", "swd_muyue", "pal_murongziying",
"swd_qiner", "pal_shenqishuang", "hs_taisi", "wangji", "pal_xingxuan", "xunyou", "hs_yelise", "pal_yuejinzhao", "pal_yueqi",
"gjqt_yuewuyi", "swd_yuxiaoxue", "ow_zhaliya", "zhangchunhua", "hs_zhihuanhua", "swd_zhiyin", "old_zhonghui", "gjqt_bailitusu",
"hs_barnes", "ow_dva", "swd_hengai", "pal_jushifang", "hs_kazhakusi", "hs_lafamu", "ow_liekong", "hs_lreno", "pal_mingxiu",
"swd_murongshi", "gw_oudimu", "gjqt_ouyangshaogong", "hs_pyros", "qinmi", "gw_sanhanya", "hs_selajin", "swd_shuwaner",
"swd_situqiang", "hs_xialikeer", "pal_xuejian", "swd_yuchiyanhong", "swd_yuwentuo", "swd_zhaoyun", "zhugeliang", "gw_aigeleisi",
"gw_aimin", "gjqt_aruan", "hs_aya", "swd_cheyun", "swd_chenjingchou", "gw_diandian", "swd_huzhongxian", "hs_jinglinglong",
"hs_kaituozhe", "hs_kalimosi", "gw_linjing", "ow_luxiao", "re_luxun", "hs_morgl", "swd_sikongyu", "hs_sthrall", "sunquan",
"sunshangxiang", "gw_yioufeisisp", "gw_yisilinni", "hs_yogg", "hs_ysera", "pal_yuntianhe", "zhugejin", "zhugeke", "gw_zhuoertan",
"hs_anduin", "swd_anka", "ow_banzang", "ow_chanyata", "diaochan", "swd_duguningke", "sp_diaochan", "hetaihou", "ns_huamulan",
"swd_huanglei", "swd_huanyuanzhi", "re_huatuo", "gw_huoge", "pal_jiangcheng", "yj_jushou", "swd_kendi", "yxs_libai",
"mtg_lilianna", "xin_liru", "liuxie", "pal_lixiaoyao", "pal_longkui", "ns_nanhua", "swd_qi", "swd_septem", "gw_shasixiwusi",
"ow_tianshi", "swd_weida", "gjqt_xiayize", "swd_xiyan", "hs_xsylvanas", "hs_yelinlonghou", "ow_yuanshi", "zuoci"];
var vintage = ["tianjian", "shuiyun", "zhuyue", "zhimeng", "poyun", "qianfang", "xfenxin", "danqing", "ywuhun", "tianwu", "xuelu",
"shahun", "yuling", "duhun", "liaoyuan", "touxi", "wangchen", "poyue", "kunlunjing", "huanhun", "yunchou", "tuzhen", "cyqiaoxie",
"mufeng", "duanyi", "guozao", "yaotong", "pozhen", "tanlin", "susheng", "jikong", "shouyin", "jilve", "hxunzhi", "huodan", "shanxian",
"ziyu", "kuoyin", "feiren", "zihui", "jidong", "baoxue", "aqianghua", "maoding", "bfengshi", "zhongdun", "pingzhang", "maichong",
"guozai", "jingxiang", "yuelu", "liechao", "fengnu", "hanshuang", "enze", "malymowang", "xshixin", "qingzun"];
var favmodes = ["versus|three", "versus|four", "versus|two", "chess|combat"];
for (var i = 0; i < mode.length; i++) {
game.saveConfig(mode[i] + "_banned", banned);
game.saveConfig(mode[i] + "_bannedcards", bannedcards);
}
var characters = lib.config.all.characters.slice(0);
characters.remove("standard");
characters.remove("old");
game.saveConfig("vintageSkills", vintage);
game.saveConfig("favouriteCharacter", favs);
game.saveConfig("favouriteMode", favmodes);
game.saveConfig("theme", "simple");
game.saveConfig("player_border", "slim");
game.saveConfig("cards", lib.config.all.cards);
game.saveConfig("characters", characters);
game.saveConfig("change_skin", false);
game.saveConfig("show_splash", "off");
game.saveConfig("show_favourite", false);
game.saveConfig("animation", false);
game.saveConfig("hover_all", false);
game.saveConfig("asset_version", "v1.9");
// game.saveConfig("characters",lib.config.all.characters);
// game.saveConfig("cards",lib.config.all.cards);
game.saveConfig("plays", ["cardpile"]);
game.saveConfig("skip_shan", false);
game.saveConfig("tao_enemy", true);
game.saveConfig("layout", "long2");
game.saveConfig("hp_style", "ol");
game.saveConfig("background_music", "music_off");
game.saveConfig("background_audio", false);
game.saveConfig("background_speak", false);
game.saveConfig("show_volumn", false);
game.saveConfig("show_replay", true);
game.saveConfig("autostyle", true);
game.saveConfig("debug", true);
game.saveConfig("dev", true);
if (!lib.device) {
game.saveConfig("sync_speed", false);
}
game.reload();
}
static o() {
ui.arena.classList.remove("observe");
}
static pt() {
var list = Array.from(arguments);
while (list.length) {
var card = cheat.gn(list.pop());
if (card) ui.cardPile.insertBefore(card, ui.cardPile.firstChild);
}
}
static q() {
if (arguments.length == 0) {
var style = ui.css.card_style;
if (lib.config.card_style != "simple") {
lib.config.card_style = "simple";
ui.css.card_style = lib.init.css(lib.assetURL + "theme/style/card", "simple");
}
else {
lib.config.card_style = "default";
ui.css.card_style = lib.init.css(lib.assetURL + "theme/style/card", "default");
}
style.remove();
}
else {
for (var i = 0; i < arguments.length; i++) {
cheat.g(arguments[i]);
}
}
ui.arena.classList.remove("selecting");
ui.arena.classList.remove("tempnoe");
}
static p(name, i, skin) {
var list = ["swd", "hs", "pal", "gjqt", "ow", "gw"];
if (!lib.character[name]) {
for (var j = 0; j < list.length; j++) {
if (lib.character[list[j] + "_" + name]) {
name = list[j] + "_" + name; break;
}
}
}
if (skin) {
lib.config.skin[name] = skin
}
var target;
if (typeof i == "number") {
target = game.players[i];
}
else {
target = game.me.next;
}
if (!lib.character[name]) {
target.node.avatar.setBackground(name, "character");
target.node.avatar.show();
}
else {
target.init(name);
}
if (i === true) {
if (lib.config.layout == "long2") {
lib.init.layout("mobile");
}
else {
lib.init.layout("long2");
}
}
}
static e() {
var cards = [], target;
for (var i = 0; i < arguments.length; i++) {
if (get.itemtype(arguments[i]) == "player") {
target = arguments[i];
}
else {
cards.push(game.createCard(arguments[i]));
}
}
if (!cards.length) {
cards.push(game.createCard("qilin"));
cards.push(game.createCard("bagua"));
cards.push(game.createCard("dilu"));
cards.push(game.createCard("chitu"));
cards.push(game.createCard("muniu"));
}
target = target || game.me;
for (var i = 0; i < cards.length; i++) {
var card = target.getEquip(cards[i]);
if (card) {
card.discard();
target.removeEquipTrigger(card);
}
target.$equip(cards[i]);
}
}
static c() {
(function () {
var a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0;
var sa = 0, sb = 0, sc = 0, sd = 0, se = 0, sf = 0, sg = 0;
for (var i in lib.character) {
switch (lib.character[i][1]) {
case "wei": a++; if (lib.config.banned.contains(i)) sa++; break;
case "shu": b++; if (lib.config.banned.contains(i)) sb++; break;
case "wu": c++; if (lib.config.banned.contains(i)) sc++; break;
case "qun": d++; if (lib.config.banned.contains(i)) sd++; break;
case "jin": g++; if (lib.config.banned.contains(i)) sg++; break;
case "western": e++; if (lib.config.banned.contains(i)) se++; break;
case "key": f++; if (lib.config.banned.contains(i)) sf++; break;
}
}
console.log("魏:" + (a - sa) + "/" + a);
console.log("蜀:" + (b - sb) + "/" + b);
console.log("吴:" + (c - sc) + "/" + c);
console.log("群:" + (d - sd) + "/" + d);
console.log("晋:" + (g - sg) + "/" + g);
console.log("西:" + (e - se) + "/" + e);
console.log("键:" + (f - sf) + "/" + f);
console.log("已启用:" + ((a + b + c + d + e + f) - (sa + sb + sc + sd + se + sf)) + "/" + (a + b + c + d + e + f));
}());
(function () {
var a = 0, b = 0, c = 0, d = 0;
var aa = 0, bb = 0, cc = 0, dd = 0;
var sa = 0, sb = 0, sc = 0, sd = 0;
var sha = 0, shan = 0, tao = 0, jiu = 0, wuxie = 0, heisha = 0, hongsha = 0;
var num = { 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0, 13: 0 };
for (var i in lib.card) {
if (get.objtype(lib.card[i]) == "object" && lib.translate[i + "_info"]) {
switch (lib.card[i].type) {
case "basic": a++; break;
case "trick": b++; break;
case "equip": c++; break;
default: d++; break;
}
}
}
for (var i = 0; i < lib.card.list.length; i++) {
if (typeof lib.card[lib.card.list[i][2]] == "object") {
switch (lib.card[lib.card.list[i][2]].type) {
case "basic": aa++; break;
case "trick": case "delay": bb++; break;
case "equip": cc++; break;
default: dd++; break;
}
switch (lib.card.list[i][0]) {
case "heart": sa++; break;
case "diamond": sb++; break;
case "club": sc++; break;
case "spade": sd++; break;
}
if (lib.card.list[i][2] == "sha") {
sha++;
if (lib.card.list[i][0] == "club" || lib.card.list[i][0] == "spade") {
heisha++;
}
else {
hongsha++;
}
}
if (lib.card.list[i][2] == "shan") {
shan++;
}
if (lib.card.list[i][2] == "tao") {
tao++;
}
if (lib.card.list[i][2] == "jiu") {
jiu++;
}
if (lib.card.list[i][2] == "wuxie") {
wuxie++;
}
num[lib.card.list[i][1]]++;
}
}
var str = "基本牌" + aa + " " + "锦囊牌" + bb + " " + "装备牌" + cc + " " + "其它牌" + dd
console.log(str);
str = "红桃牌" + sa + " " + "方片牌" + sb + " " + "梅花牌" + sc + " " + "黑桃牌" + sd
console.log(str);
str = "杀" + sha + " " + "黑杀" + heisha + " " + "红杀" + hongsha + " " + "闪" + shan + " " + "桃" + tao + " " + "酒" + jiu + " " + "无懈" + wuxie
console.log(str);
if (arguments[1]) {
for (var i = 1; i <= 13; i++) {
if (i < 10) {
console.log(i + " ", num[i]);
}
else {
console.log(i, num[i]);
}
}
}
var arr = [];
for (var i = 1; i <= 13; i++) {
arr.push(num[i]);
}
console.log((a + b + c + d) + "/" + (aa + bb + cc + dd), ...arr)
}());
}
static id() {
game.showIdentity();
}
static b() {
if (!ui.dialog || !ui.dialog.buttons) return;
for (var i = 0; i < Math.min(arguments.length, ui.dialog.buttons.length); i++) {
ui.dialog.buttons[i].link = arguments[i];
}
}
static uy(me) {
if (me) {
game.me.useCard({ name: "spell_yexinglanghun" }, game.me);
}
else {
var enemy = game.me.getEnemy();
enemy.useCard({ name: "spell_yexinglanghun" }, enemy);
}
}
static gs(name, act) {
var card = game.createCard("spell_" + (name || "yexinglanghun"));
game.me.node.handcards1.appendChild(card);
if (!act) {
game.me.actused = -99;
}
ui.updatehl();
delete _status.event._cardChoice;
delete _status.event._targetChoice;
delete _status.event._skillChoice;
setTimeout(game.check, 300);
}
static gc(name, act) {
var card = game.createCard("stone_" + (name || "falifulong") + "_stonecharacter");
game.me.node.handcards1.appendChild(card);
if (!act) {
game.me.actused = -99;
}
ui.updatehl();
delete _status.event._cardChoice;
delete _status.event._targetChoice;
delete _status.event._skillChoice;
setTimeout(game.check, 300);
}
static a(bool) {
if (lib.config.test_game) {
game.saveConfig("test_game");
}
else {
if (bool) {
if (typeof bool === "string") {
game.saveConfig("test_game", bool);
}
else {
game.saveConfig("test_game", "_");
}
}
else {
game.saveConfig("test_game", true);
}
}
game.reload();
}
static as() {
ui.window.classList.remove("testing");
var bg = ui.window.querySelector(".pausedbg");
if (bg) {
bg.remove();
}
}
static uj() {
cheat.e("qilin");
game.me.next.useCard({ name: "jiedao" }, [game.me, game.me.previous]);
}
static u() {
var card = { name: "sha" }, source = game.me.next, targets = [];
for (var i = 0; i < arguments.length; i++) {
if (get.itemtype(arguments[i]) == "player") {
source = arguments[i];
}
else if (Array.isArray(arguments[i])) {
targets = arguments[i];
}
else if (typeof arguments[i] == "object" && arguments[i]) {
card = arguments[i];
}
else if (typeof arguments[i] == "string") {
card = { name: arguments[i] }
}
}
if (!targets.length) targets.push(game.me);
source.useCard(game.createCard(card.name, card.suit, card.number, card.nature), targets);
}
static r(bool) {
var list = ["s", "ap", "a", "am", "bp", "b", "bm", "c", "d"];
var str = "";
for (var i = 0; i < list.length; i++) {
if (str) str += " 、 ";
str += list[i] + "-" + lib.rank[list[i]].length;
}
console.log(str);
for (var i in lib.characterPack) {
if (!bool && lib.config.all.sgscharacters.contains(i)) continue;
var map = {};
var str = "";
for (var j in lib.characterPack[i]) {
var rank = get.rank(j);
if (!map[rank]) {
map[rank] = 1;
}
else {
map[rank]++;
}
}
for (var j = 0; j < list.length; j++) {
if (map[list[j]]) {
if (str) str += " 、 ";
str += list[j] + "-" + map[list[j]];
}
}
if (str) {
console.log(lib.translate[i + "_character_config"] + "" + str);
}
}
var list = lib.rank.s.concat(lib.rank.ap).concat(lib.rank.a).concat(lib.rank.am).
concat(lib.rank.bp).concat(lib.rank.b).concat(lib.rank.bm).concat(lib.rank.c).concat(lib.rank.d);
Object.keys(lib.character).forEach(key => {
if (!lib.config.forbidai.includes(key) && !key.startsWith("boss_") && !key.startsWith("tafang_") && !list.includes(key)) console.log(get.translation(key), key);
});
}
static h(player) {
console.log(get.translation(player.getCards("h")));
}
static g() {
for (var i = 0; i < arguments.length; i++) {
if (i > 0 && typeof arguments[i] == "number") {
for (var j = 0; j < arguments[i] - 1; j++) {
cheat.gx(arguments[i - 1]);
}
}
else {
cheat.gx(arguments[i]);
}
}
}
static ga(type) {
for (var i in lib.card) {
if (lib.card[i].type == type || lib.card[i].subtype == type) {
cheat.g(i);
}
}
}
static gg() {
for (var i = 0; i < game.players.length; i++) {
for (var j = 0; j < arguments.length; j++) {
cheat.gx(arguments[j], game.players[i]);
}
}
}
static gx(name, target) {
target = target || game.me;
var card = cheat.gn(name);
if (!card) return;
target.node.handcards1.appendChild(card);
delete _status.event._cardChoice;
delete _status.event._targetChoice;
delete _status.event._skillChoice;
game.check();
target.update();
ui.updatehl();
}
static gn(name) {
var nature = null;
var suit = null;
var suits = ["club", "spade", "diamond", "heart"];
for (var i = 0; i < suits.length; i++) {
if (name.startsWith(suits[i])) {
suit = suits[i];
name = name.slice(suits[i].length);
break;
}
}
if (name.startsWith("red")) {
name = name.slice(3);
suit = ["diamond", "heart"].randomGet();
}
if (name.startsWith("black")) {
name = name.slice(5);
suit = ["spade", "club"].randomGet();
}
if (name == "huosha") {
name = "sha";
nature = "fire";
}
else if (name == "leisha") {
name = "sha";
nature = "thunder";
}
if (!lib.card[name]) {
return null;
}
return game.createCard(name, suit, null, nature);
}
static ge(target) {
if (target) {
cheat.gx("zhuge", target);
cheat.gx("qinglong", target);
cheat.gx("bagua", target);
cheat.gx("dilu", target);
cheat.gx("chitu", target);
cheat.gx("muniu", target);
}
else {
cheat.g("zhuge");
cheat.g("qinglong");
cheat.g("bagua");
cheat.g("dilu");
cheat.g("chitu");
cheat.g("muniu");
}
}
static gj() {
cheat.g("shandian");
cheat.g("huoshan");
cheat.g("hongshui");
cheat.g("lebu");
cheat.g("bingliang");
cheat.g("guiyoujie");
}
static gf() {
for (var i in lib.card) {
if (lib.card[i].type == "food") {
cheat.g(i);
}
}
}
static d(num, target) {
if (num == undefined) num = 1;
var cards = get.cards(num);
for (var i = 0; i < num; i++) {
var card = cards[i];
game.me.node.handcards1.appendChild(card);
delete _status.event._cardChoice;
delete _status.event._targetChoice;
delete _status.event._skillChoice;
game.check();
game.me.update();
ui.updatehl();
}
}
static s() {
for (var i = 0; i < arguments.length; i++) {
game.me.addSkill(arguments[i], true);
}
delete _status.event._cardChoice;
delete _status.event._targetChoice;
delete _status.event._skillChoice;
game.check();
}
static t(num) {
if (game.players.contains(num)) {
num = game.players.indexOf(num);
}
if (num == undefined) {
for (var i = 0; i < game.players.length; i++) cheat.t(i);
return;
}
var player = game.players[num];
var cards = player.getCards("hej");
for (var i = 0; i < cards.length; i++) {
cards[i].discard();
}
player.removeEquipTrigger();
player.update();
}
static to() {
for (var i = 0; i < game.players.length; i++) {
if (game.players[i] != game.me) {
cheat.t(i);
}
}
}
static tm() {
for (var i = 0; i < game.players.length; i++) {
if (game.players[i] == game.me) {
cheat.t(i);
}
}
}
static k(i) {
if (i == undefined) i = 1;
game.players[i].hp = 1;
cheat.t(i);
cheat.g("juedou");
}
static z(name) {
switch (name) {
case "cc": name = "re_caocao"; break;
case "lb": name = "re_liubei"; break;
case "sq": name = "sunquan"; break;
case "dz": name = "dongzhuo"; break;
case "ys": name = "re_yuanshao"; break;
case "zj": name = "sp_zhangjiao"; break;
case "ls": name = "liushan"; break;
case "sc": name = "sunce"; break;
case "cp": name = "caopi"; break;
case "cr": name = "caorui"; break;
case "sx": name = "sunxiu"; break;
case "lc": name = "liuchen"; break;
case "sh": name = "sunhao"; break;
}
game.zhu.init(name);
game.zhu.maxHp++;
game.zhu.hp++;
game.zhu.update();
}
}

View File

@ -1,5 +0,0 @@
export const color = {
black: ["club", "spade"],
red: ["diamond", "heart"],
none: ["none"]
};

View File

@ -1,41 +0,0 @@
export class Comparator {
constructor() {
throw new TypeError(`${new.target.name} is not a constructor`);
}
static equals() {
if (arguments.length == 0) return false;
if (arguments.length == 1) return true;
for (let i = 1; i < arguments.length; ++i) if (arguments[i] !== arguments[0]) return false;
return true;
}
static equalAny() {
if (arguments.length == 0) return false;
if (arguments.length == 1) return true;
for (let i = 1; i < arguments.length; ++i) if (arguments[i] === arguments[0]) return true;
return false;
}
static notEquals() {
if (arguments.length == 0) return false;
if (arguments.length == 1) return true;
for (let i = 1; i < arguments.length; ++i) if (arguments[i] === arguments[0]) return false;
return true;
}
static notEqualAny() {
if (arguments.length == 0) return false;
if (arguments.length == 1) return true;
for (let i = 1; i < arguments.length; ++i) if (arguments[i] !== arguments[0]) return true;
return false;
}
static typeEquals() {
if (arguments.length == 0) return false;
if (arguments.length == 1) return arguments[0] !== null;
const type = typeof arguments[0];
for (let i = 1; i < arguments.length; ++i) if (type !== arguments[i]) return false;
return true;
}
}

View File

@ -1,15 +0,0 @@
import { APPEARANCE } from "./configuration-menu/appearance.js";
import { AUDIO } from "./configuration-menu/audio.js";
import { GENERAL } from "./configuration-menu/general.js";
import { OTHERS } from "./configuration-menu/others.js";
import { SKILL } from "./configuration-menu/skill.js";
import { VIEW } from "./configuration-menu/view.js";
export const CONFIGURATION_MENU = {
general: GENERAL,
appearence: APPEARANCE,
view: VIEW,
audio: AUDIO,
skill: SKILL,
others: OTHERS
};

View File

@ -1,6 +0,0 @@
import { CONFIGURATION } from "./appearance/configuration.js";
export const APPEARANCE = {
name: "外观",
config: CONFIGURATION
};

View File

@ -1,187 +0,0 @@
import { ANIMATION } from "./configuration/animation.js";
import { AUTOMATIC_BORDER_COUNT } from "./configuration/automatic-border-count.js";
import { AUTOMATIC_BORDER_START } from "./configuration/automatic-border-start.js";
import { BLUR_UI } from "./configuration/blur-ui.js";
import { BORDER_STYLE } from "./configuration/border-style.js";
import { BUTTON_CHARACTER_PREFIX } from "./configuration/button-character-prefix.js";
import { BUTTON_CHARACTER_STYLE } from "./configuration/button-character-style.js";
import { BUTTON_PRESS } from "./configuration/button-press.js";
import { CARD_BACK_STYLE } from "./configuration/card-back-style.js";
import { CARD_SHAPE } from "./configuration/card-shape.js";
import { CARD_STYLE } from "./configuration/card-style.js";
import { CARD_TEMPORARY_NAME } from "./configuration/card-temporary-name.js";
import { CARD_TEXT_FONT } from "./configuration/card-text-font.js";
import { CHANGE_SKIN_AUTOMATICALLY } from "./configuration/change-skin-automatically.js";
import { CHANGE_SKIN } from "./configuration/change-skin.js";
import { CONTROL_STYLE } from "./configuration/control-style.js";
import { CURSOR_STYLE } from "./configuration/cursor-style.js";
import { CUSTOM_BUTTON_CONTROL_BOTTOM } from "./configuration/custom-button-control-bottom.js";
import { CUSTOM_BUTTON_CONTROL_TOP } from "./configuration/custom-button-control-top.js";
import { CUSTOM_BUTTON_SYSTEM_BOTTOM } from "./configuration/custom-button-system-bottom.js";
import { CUSTOM_BUTTON_SYSTEM_TOP } from "./configuration/custom-button-system-top.js";
import { CUSTOM_BUTTON } from "./configuration/custom-button.js";
import { DAMAGE_SHAKE } from "./configuration/damage-shake.js";
import { DIE_MOVE } from "./configuration/die-move.js";
import { FOLD_CARD } from "./configuration/fold-card.js";
import { FOLD_MODE } from "./configuration/fold-mode.js";
import { GLASS_UI } from "./configuration/glass-ui.js";
import { GLOBAL_FONT } from "./configuration/global-font.js";
import { GLOW_PHASE } from "./configuration/glow-phase.js";
import { HP_STYLE } from "./configuration/hp-style.js";
import { IDENTITY_FONT } from "./configuration/identity-font.js";
import { IMAGE_BACKGROUND_BLUR } from "./configuration/image-background-blur.js";
import { IMAGE_BACKGROUND_RANDOM } from "./configuration/image-background-random.js";
import { IMAGE_BACKGROUND } from "./configuration/image-background.js";
import { JIU_EFFECT } from "./configuration/jiu-effect.js";
import { LAYOUT } from "./configuration/layout.js";
import { LINK_STYLE_2 } from "./configuration/link-style-2.js";
import { MENU_STYLE } from "./configuration/menu-style.js";
import { NAME_FONT } from "./configuration/name-font.js";
import { PHONE_LAYOUT } from "./configuration/phone-layout.js";
import { PLAYER_BORDER } from "./configuration/player-border.js";
import { PLAYER_HEIGHT_NOVA } from "./configuration/player-height-nova.js";
import { PLAYER_HEIGHT } from "./configuration/player-height.js";
import { PLAYER_STYLE } from "./configuration/player-style.js";
import { RADIUS_SIZE } from "./configuration/radius-size.js";
import { SEPARATE_CONTROL } from "./configuration/separate-control.js";
import { SKILL_ANIMATION_TYPE } from "./configuration/skill-animation-type.js";
import { SPLASH_STYLE } from "./configuration/splash-style.js";
import { SUITS_FONT } from "./configuration/suits-font.js";
import { TARGET_SHAKE } from "./configuration/target-shake.js";
import { THEME } from "./configuration/theme.js";
import { TURNED_STYLE } from "./configuration/turned-style.js";
import { UI_ZOOM } from "./configuration/ui-zoom.js";
export const CONFIGURATION = {
theme: THEME,
layout: LAYOUT,
splash_style: SPLASH_STYLE,
player_height: PLAYER_HEIGHT,
player_height_nova: PLAYER_HEIGHT_NOVA,
ui_zoom: UI_ZOOM,
image_background: IMAGE_BACKGROUND,
image_background_random: IMAGE_BACKGROUND_RANDOM,
image_background_blur: IMAGE_BACKGROUND_BLUR,
phonelayout: PHONE_LAYOUT,
change_skin: CHANGE_SKIN,
change_skin_auto: CHANGE_SKIN_AUTOMATICALLY,
card_style: CARD_STYLE,
cardback_style: CARD_BACK_STYLE,
hp_style: HP_STYLE,
player_style: PLAYER_STYLE,
border_style: BORDER_STYLE,
autoborder_count: AUTOMATIC_BORDER_COUNT,
autoborder_start: AUTOMATIC_BORDER_START,
player_border: PLAYER_BORDER,
menu_style: MENU_STYLE,
control_style: CONTROL_STYLE,
custom_button: CUSTOM_BUTTON,
custom_button_system_top: CUSTOM_BUTTON_SYSTEM_TOP,
custom_button_system_bottom: CUSTOM_BUTTON_SYSTEM_BOTTOM,
custom_button_control_top: CUSTOM_BUTTON_CONTROL_TOP,
custom_button_control_bottom: CUSTOM_BUTTON_CONTROL_BOTTOM,
radius_size: RADIUS_SIZE,
glow_phase: GLOW_PHASE,
fold_card: FOLD_CARD,
fold_mode: FOLD_MODE,
seperate_control: SEPARATE_CONTROL,
blur_ui: BLUR_UI,
glass_ui: GLASS_UI,
damage_shake: DAMAGE_SHAKE,
button_press: BUTTON_PRESS,
jiu_effect: JIU_EFFECT,
animation: ANIMATION,
skill_animation_type: SKILL_ANIMATION_TYPE,
die_move: DIE_MOVE,
target_shake: TARGET_SHAKE,
turned_style: TURNED_STYLE,
link_style2: LINK_STYLE_2,
cardshape: CARD_SHAPE,
cardtempname: CARD_TEMPORARY_NAME,
buttoncharacter_style: BUTTON_CHARACTER_STYLE,
buttoncharacter_prefix: BUTTON_CHARACTER_PREFIX,
cursor_style: CURSOR_STYLE,
name_font: NAME_FONT,
identity_font: IDENTITY_FONT,
cardtext_font: CARD_TEXT_FONT,
global_font: GLOBAL_FONT,
suits_font: SUITS_FONT,
update(config, map) {
if (config.custom_button) {
map.custom_button_system_top.show();
map.custom_button_system_bottom.show();
map.custom_button_control_top.show();
map.custom_button_control_bottom.show();
}
else {
map.custom_button_system_top.hide();
map.custom_button_system_bottom.hide();
map.custom_button_control_top.hide();
map.custom_button_control_bottom.hide();
}
if (config.change_skin) {
map.change_skin_auto.show();
}
else {
map.change_skin_auto.hide();
}
if (config.image_background_random) {
map.image_background_blur.show();
map.image_background.hide();
}
else {
map.image_background.show();
if (config.image_background == "default") {
map.image_background_blur.hide();
}
else {
map.image_background_blur.show();
}
}
if (config.layout == "long" || config.layout == "mobile") {
map.cardshape.show();
map.phonelayout.show();
}
else {
if (config.layout == "long2" || config.layout == "nova") {
map.phonelayout.show();
map.cardshape.show();
}
else {
map.phonelayout.hide();
map.cardshape.hide();
}
}
if (config.layout == "long") {
map.player_height.show();
}
else {
if (config.layout == "long2") {
map.player_height.show();
}
else {
map.player_height.hide();
}
}
if (config.layout == "nova") {
map.player_height_nova.show();
}
else {
map.player_height_nova.hide();
}
if (config.touchscreen) {
map.cursor_style.hide();
}
else {
map.cursor_style.show();
}
if (config.border_style == "auto") {
map.autoborder_count.show();
map.autoborder_start.show();
}
else {
map.autoborder_count.hide();
map.autoborder_start.hide();
}
}
};

View File

@ -1,6 +0,0 @@
export const ANIMATION = {
name: "游戏特效",
intro: "开启后出现属性伤害、回复体力等情况时会显示动画",
init: false,
unfrequent: true
};

View File

@ -1,20 +0,0 @@
import { ITEM } from "./automatic-border-count/item.js";
const introduction = document.createElement("body");
const kill = document.createElement("strong");
kill.append("击杀");
introduction.append(kill, " 每击杀一人,边框提升两级", document.createElement("br"));
const damage = document.createElement("strong");
damage.append("伤害");
introduction.append(damage, " 每造成两点伤害,边框提升一级", document.createElement("br"));
const mix = document.createElement("strong");
mix.append("混合");
introduction.append(mix, " 击杀量决定边框颜色,伤害量决定边框装饰");
export const AUTOMATIC_BORDER_COUNT = {
name: "边框升级方式",
intro: introduction.innerHTML,
init: "kill",
item: ITEM,
unfrequent: true
};

View File

@ -1,5 +0,0 @@
export const ITEM = {
kill: "击杀",
damage: "伤害",
mix: "混合"
};

View File

@ -1,8 +0,0 @@
import { ITEM } from "./automatic-border-start/item.js";
export const AUTOMATIC_BORDER_START = {
name: "基础边框颜色",
init: "bronze",
item: ITEM,
unfrequent: true
};

View File

@ -1,5 +0,0 @@
export const ITEM = {
bronze: "铜",
silver: "银",
gold: "金"
};

View File

@ -1,15 +0,0 @@
export const BLUR_UI = {
name: "模糊效果",
intro: "在暂停或打开菜单时开启模糊效果",
init: false,
unfrequent: true,
onclick(bool) {
game.saveConfig("blur_ui", bool);
if (bool) {
ui.window.classList.add("blur_ui");
}
else {
ui.window.classList.remove("blur_ui");
}
}
};

View File

@ -1,125 +0,0 @@
import { ITEM } from "./border-style/item.js";
export const BORDER_STYLE = {
name: "角色边框",
init: "default",
intro: "设置角色边框的样式,当设为自动时,样式将随着一局游戏中伤害或击杀的数量自动改变",
item: ITEM,
visualBar(node, item, create, switcher) {
if (node.created) {
return;
}
var button;
for (var i = 0; i < node.parentNode.childElementCount; i++) {
if (node.parentNode.childNodes[i]._link == "custom") {
button = node.parentNode.childNodes[i];
}
}
if (!button) {
return;
}
node.created = true;
var deletepic;
ui.create.filediv(".menubutton", "添加图片", node, function (file) {
if (file) {
game.putDB("image", "border_style", file, function () {
game.getDB("image", "border_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
button.style.backgroundImage = "url(" + data + ")";
button.className = "button character";
button.style.backgroundSize = "100% 100%";
node.classList.add("showdelete");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
});
}
}).inputNode.accept = "image/*";
deletepic = ui.create.div(".menubutton.deletebutton", "删除图片", node, function () {
if (confirm("确定删除自定义图片?(此操作不可撤销)")) {
game.deleteDB("image", "border_style");
button.style.backgroundImage = "none";
button.className = "button character dashedmenubutton";
node.classList.remove("showdelete");
if (lib.config.border_style == "custom") {
lib.configMenu.appearence.config.border_style.onclick("default");
switcher.lastChild.innerHTML = "默认";
}
button.classList.add("transparent");
}
});
},
visualMenu(node, link, name, config) {
node.className = "button character";
node.style.backgroundSize = "";
node.style.height = "108px";
node.dataset.decoration = "";
if (link == "default" || link == "custom" || link == "auto") {
node.style.backgroundImage = "none";
node.className = "button character dashedmenubutton";
}
else {
if (link.startsWith("dragon_")) {
link = link.slice(7);
node.dataset.decoration = link;
}
node.setBackgroundImage("theme/style/player/" + link + "1.png");
node.style.backgroundSize = "100% 100%";
}
if (link == "custom") {
node.classList.add("transparent");
game.getDB("image", "border_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
node.style.backgroundImage = "url(" + data + ")";
node.className = "button character";
node.parentNode.lastChild.classList.add("showdelete");
node.style.backgroundSize = "100% 100%";
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
onclick(layout) {
game.saveConfig("border_style", layout);
if (ui.css.border_stylesheet) {
ui.css.border_stylesheet.remove();
delete ui.css.border_stylesheet;
}
if (layout == "custom") {
game.getDB("image", "border_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.border_stylesheet) {
ui.css.border_stylesheet.remove();
}
ui.css.border_stylesheet = lib.init.sheet();
ui.css.border_stylesheet.id = "ui.css.border";
ui.css.border_stylesheet.sheet.insertRule(`#window .player>.framebg{display:block;background-image:url("${fileLoadedEvent.target.result}")}`, 0);
ui.css.border_stylesheet.sheet.insertRule(".player>.count{z-index: 3 !important;border-radius: 2px !important;text-align: center !important;}", 0);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
else if (layout != "default" && layout != "auto") {
ui.css.border_stylesheet = lib.init.sheet();
if (layout.startsWith("dragon_")) {
layout = layout.slice(7);
ui.arena.dataset.framedecoration = layout;
}
else {
ui.arena.dataset.framedecoration = "";
}
ui.css.border_stylesheet.sheet.insertRule(`#window .player>.framebg,#window #arena.long.mobile:not(.fewplayer) .player[data-position="0"]>.framebg{display:block;background-image:url("${lib.assetURL}theme/style/player/${layout}1.png")}`, 0);
ui.css.border_stylesheet.sheet.insertRule(`#window #arena.long:not(.fewplayer) .player>.framebg, #arena.oldlayout .player>.framebg{background-image:url("${lib.assetURL}theme/style/player/${layout}3.png")}`, 0);
ui.css.border_stylesheet.sheet.insertRule(".player>.count{z-index: 3 !important;border-radius: 2px !important;text-align: center !important;}", 0);
}
},
unfrequent: true
};

View File

@ -1,11 +0,0 @@
export const ITEM = {
gold: "金框",
silver: "银框",
bronze: "铜框",
dragon_gold: "金龙",
dragon_silver: "银龙",
dragon_bronze: "玉龙",
custom: "自定",
auto: "自动",
default: "默认"
};

View File

@ -1,8 +0,0 @@
import { ITEM } from "./button-character-prefix/item.js";
export const BUTTON_CHARACTER_PREFIX = {
name: "武将前缀",
init: "default",
item: ITEM,
unfrequent: true
};

View File

@ -1,5 +0,0 @@
export const ITEM = {
default: "默认",
simple: "不显示颜色",
off: "不显示前缀"
};

View File

@ -1,8 +0,0 @@
import { ITEM } from "./button-character-style/item.js";
export const BUTTON_CHARACTER_STYLE = {
name: "选将样式",
init: "default",
item: ITEM,
unfrequent: true
};

View File

@ -1,5 +0,0 @@
export const ITEM = {
default: "默认",
simple: "精简",
old: "旧版"
};

View File

@ -1,6 +0,0 @@
export const BUTTON_PRESS = {
name: "按钮效果",
intro: "选项条被按下时将有按下效果",
init: true,
unfrequent: true
};

View File

@ -1,138 +0,0 @@
import { ITEM } from "./card-back-style/item.js";
export const CARD_BACK_STYLE = {
name: "卡背样式",
intro: "设置背面朝上的卡牌的样式",
init: "default",
item: ITEM,
visualBar(node, item, create, switcher) {
if (node.created) {
return;
}
var button;
for (var i = 0; i < node.parentNode.childElementCount; i++) {
if (node.parentNode.childNodes[i]._link == "custom") {
button = node.parentNode.childNodes[i];
}
}
if (!button) {
return;
}
node.created = true;
var deletepic;
ui.create.filediv(".menubutton", "添加图片", node, function (file) {
if (file) {
game.putDB("image", "cardback_style", file, function () {
game.getDB("image", "cardback_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
button.style.backgroundImage = "url(" + data + ")";
button.className = "button character";
node.classList.add("showdelete");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
});
}
}).inputNode.accept = "image/*";
ui.create.filediv(".menubutton.deletebutton.addbutton", "添加翻转图片", node, function (file) {
if (file) {
game.putDB("image", "cardback_style2", file, function () {
node.classList.add("hideadd");
});
}
}).inputNode.accept = "image/*";
deletepic = ui.create.div(".menubutton.deletebutton", "删除图片", node, function () {
if (confirm("确定删除自定义图片?(此操作不可撤销)")) {
game.deleteDB("image", "cardback_style");
game.deleteDB("image", "cardback_style2");
button.style.backgroundImage = "none";
button.className = "button character dashedmenubutton";
node.classList.remove("showdelete");
node.classList.remove("hideadd");
if (lib.config.cardback_style == "custom") {
lib.configMenu.appearence.config.cardback_style.onclick("default");
switcher.lastChild.innerHTML = "默认";
}
button.classList.add("transparent");
}
});
},
visualMenu(node, link, name, config) {
node.style.backgroundSize = "100% 100%";
switch (link) {
case "default": case "custom": {
node.style.backgroundImage = "none";
node.className = "button character dashedmenubutton";
break;
}
case "new": node.className = "button character"; node.setBackgroundImage("theme/style/cardback/image/new.png"); break;
case "feicheng": node.className = "button character"; node.setBackgroundImage("theme/style/cardback/image/feicheng.png"); break;
case "official": node.className = "button character"; node.setBackgroundImage("theme/style/cardback/image/official.png"); break;
case "liusha": node.className = "button character"; node.setBackgroundImage("theme/style/cardback/image/liusha.png"); break;
case "ol": node.className = "button character"; node.setBackgroundImage("theme/style/cardback/image/ol.png"); break;
case "wood": node.className = "button card fullskin"; node.setBackgroundImage("theme/woodden/wood.jpg"); node.style.backgroundSize = "initial"; break;
case "music": node.className = "button card fullskin"; node.setBackgroundImage("theme/music/wood3.png"); break;
}
if (link == "custom") {
node.classList.add("transparent");
game.getDB("image", "cardback_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
node.style.backgroundImage = "url(" + data + ")";
node.className = "button character";
node.parentNode.lastChild.classList.add("showdelete");
game.getDB("image", "cardback_style2", function (file) {
if (file) {
node.parentNode.lastChild.classList.add("hideadd");
}
});
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
onclick(layout) {
game.saveConfig("cardback_style", layout);
var style = ui.css.cardback_style;
ui.css.cardback_style = lib.init.css(lib.assetURL + "theme/style/cardback", lib.config.cardback_style);
style.remove();
if (ui.css.cardback_stylesheet) {
ui.css.cardback_stylesheet.remove();
delete ui.css.cardback_stylesheet;
}
if (ui.css.cardback_stylesheet2) {
ui.css.cardback_stylesheet2.remove();
delete ui.css.cardback_stylesheet2;
}
if (layout == "custom") {
game.getDB("image", "cardback_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.cardback_stylesheet) {
ui.css.cardback_stylesheet.remove();
}
ui.css.cardback_stylesheet = lib.init.sheet(".card:empty,.card.infohidden{background-image:url(" + fileLoadedEvent.target.result + ")}");
game.getDB("image", "cardback_style2", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.cardback_stylesheet2) {
ui.css.cardback_stylesheet2.remove();
}
ui.css.cardback_stylesheet2 = lib.init.sheet(".card.infohidden:not(.infoflip){background-image:url(" + fileLoadedEvent.target.result + ")}");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
unfrequent: true
};

View File

@ -1,8 +0,0 @@
export const ITEM = {
official: "原版",
feicheng: "废城",
liusha: "流沙",
ol: "手杀",
custom: "自定",
default: "默认"
};

View File

@ -1,34 +0,0 @@
import { ITEM } from "./card-shape/item.js";
export const CARD_SHAPE = {
name: "手牌显示",
intro: "将手牌设置为正方形或长方形",
init: "default",
unfrequent: true,
item: ITEM,
onclick(item) {
var linked = false;
if (game.me && game.me.isLinked()) {
linked = true;
}
game.saveConfig("cardshape", item);
if (item == "oblong" && (game.layout == "long" || game.layout == "mobile" || game.layout == "long2" || game.layout == "nova")) {
ui.arena.classList.add("oblongcard");
ui.window.classList.add("oblongcard");
}
else {
ui.arena.classList.remove("oblongcard");
ui.window.classList.remove("oblongcard");
}
if (linked) {
if (get.is.linked2(game.me)) {
game.me.classList.remove("linked");
game.me.classList.add("linked2");
}
else {
game.me.classList.add("linked");
game.me.classList.remove("linked2");
}
}
}
};

View File

@ -1,4 +0,0 @@
export const ITEM = {
default: "默认",
oblong: "长方"
};

View File

@ -1,114 +0,0 @@
import { ITEM } from "./card-style/item.js";
export const CARD_STYLE = {
name: "卡牌样式",
init: "default",
intro: "设置正面朝上的卡牌的样式",
item: ITEM,
visualBar(node, item, create, switcher) {
if (node.created) {
return;
}
var button;
for (var i = 0; i < node.parentNode.childElementCount; i++) {
if (node.parentNode.childNodes[i]._link == "custom") {
button = node.parentNode.childNodes[i];
}
}
if (!button) {
return;
}
node.created = true;
var deletepic;
ui.create.filediv(".menubutton", "添加图片", node, function (file) {
if (file) {
game.putDB("image", "card_style", file, function () {
game.getDB("image", "card_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
button.style.backgroundImage = "url(" + data + ")";
button.className = "button card fullskin";
node.classList.add("showdelete");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
});
}
}).inputNode.accept = "image*";
deletepic = ui.create.div(".menubutton.deletebutton", "删除图片", node, function () {
if (confirm("确定删除自定义图片?(此操作不可撤销)")) {
game.deleteDB("image", "card_style");
button.style.backgroundImage = "none";
button.className = "button character dashedmenubutton";
node.classList.remove("showdelete");
if (lib.config.card_style == "custom") {
lib.configMenu.appearence.config.card_style.onclick("default");
switcher.lastChild.innerHTML = "默认";
}
button.classList.add("transparent");
}
});
},
visualMenu(node, link, name, config) {
node.className = "button card fullskin";
node.style.backgroundSize = "100% 100%";
switch (link) {
case "default": case "custom": {
if (lib.config.theme == "simple") {
node.style.backgroundImage = "linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4))";
node.className = "button character";
}
else {
node.style.backgroundImage = "none";
node.className = "button character dashedmenubutton";
}
break;
}
case "new": node.setBackgroundImage("theme/style/card/image/new.png"); break;
case "ol": node.setBackgroundImage("theme/style/card/image/ol.png"); break;
case "wood": node.setBackgroundImage("theme/woodden/wood.jpg"); node.style.backgroundSize = "initial"; break;
case "music": node.setBackgroundImage("theme/music/wood3.png"); break;
case "simple": node.setBackgroundImage("theme/simple/card.png"); break;
}
if (link == "custom") {
node.classList.add("transparent");
game.getDB("image", "card_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
node.style.backgroundImage = "url(" + data + ")";
node.className = "button card fullskin";
node.parentNode.lastChild.classList.add("showdelete");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
onclick(layout) {
game.saveConfig("card_style", layout);
var style = ui.css.card_style;
ui.css.card_style = lib.init.css(lib.assetURL + "theme/style/card", lib.config.card_style);
style.remove();
if (ui.css.card_stylesheet) {
ui.css.card_stylesheet.remove();
delete ui.css.card_stylesheet;
}
if (layout == "custom") {
game.getDB("image", "card_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.card_stylesheet) {
ui.css.card_stylesheet.remove();
}
ui.css.card_stylesheet = lib.init.sheet(".card:not(*:empty){background-image:url(" + fileLoadedEvent.target.result + ")}");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
unfrequent: true
};

View File

@ -1,8 +0,0 @@
export const ITEM = {
wood: "木纹",
music: "音乐",
simple: "原版",
ol: "手杀",
custom: "自定",
default: "默认"
};

View File

@ -1,28 +0,0 @@
import { ITEM } from "./card-temporary-name/item.js";
export const CARD_TEMPORARY_NAME = {
name: "视为卡牌名称显示",
intro: "显示强制视为类卡牌(如武魂),包括拆顺对话框内的判定牌(国色)转换等名称的显示方式",
init: "image",
unfrequent: true,
item: ITEM,
onclick(item) {
game.saveConfig("cardtempname", item);
if (!game.me || !game.me.getCards) return;
var hs = game.me.getCards("h");
for (var i = 0; i < hs.length; i++) {
if (hs[i]._tempName) {
switch (item) {
case "default":
case "horizon":
case "image":
ui.create.cardTempName(hs[i]);
break;
default:
hs[i]._tempName.delete();
delete hs[i]._tempName;
}
}
}
}
};

View File

@ -1,6 +0,0 @@
export const ITEM = {
default: "纵向",
horizon: "横向",
image: "图片",
off: "禁用"
};

View File

@ -1,18 +0,0 @@
import { ITEM } from "./card-text-font/item.js";
export const CARD_TEXT_FONT = {
name: "卡牌字体",
init: "default",
unfrequent: true,
item: ITEM,
textMenu(node, link) {
if (link != "default") {
node.style.fontFamily = link;
}
node.style.fontSize = "20px";
},
onclick(font) {
game.saveConfig("cardtext_font", font);
lib.init.cssstyles();
}
};

View File

@ -1,18 +0,0 @@
import { Game } from "../../../../game.js";
import { status } from "../../../../status.js";
import { Click } from "../../../../ui/click.js";
import { ITEM } from "./change-skin-automatically/item.js";
export const CHANGE_SKIN_AUTOMATICALLY = {
name: "自动换肤",
init: "off",
item: ITEM,
intro: "游戏每进行一段时间自动为一个随机角色更换皮肤",
onclick(item) {
Game.saveConfig("change_skin_auto", item);
clearTimeout(status.skintimeout);
if (item != "off") {
status.skintimeout = setTimeout(Click.autoskin, parseInt(item));
}
}
};

View File

@ -1,7 +0,0 @@
export const ITEM = {
off: "关闭",
"30000": "半分钟",
"60000": "一分钟",
"120000": "两分钟",
"300000": "五分钟"
};

View File

@ -1,5 +0,0 @@
export const CHANGE_SKIN = {
name: "开启换肤",
init: true,
intro: "在武将的右键菜单中换肤,皮肤可在选项-文件-图片文件-皮肤图片中添加"
};

View File

@ -1,116 +0,0 @@
import { ITEM } from "./control-style/item.js";
export const CONTROL_STYLE = {
name: "按钮背景",
init: "default",
item: ITEM,
visualBar(node, item, create, switcher) {
if (node.created) {
return;
}
var button;
for (var i = 0; i < node.parentNode.childElementCount; i++) {
if (node.parentNode.childNodes[i]._link == "custom") {
button = node.parentNode.childNodes[i];
}
}
if (!button) {
return;
}
node.created = true;
var deletepic;
ui.create.filediv(".menubutton", "添加图片", node, function (file) {
if (file) {
game.putDB("image", "control_style", file, function () {
game.getDB("image", "control_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
button.style.backgroundImage = "url(" + data + ")";
button.className = "button character controlbutton";
node.classList.add("showdelete");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
});
}
}).inputNode.accept = "image/*";
deletepic = ui.create.div(".menubutton.deletebutton", "删除图片", node, function () {
if (confirm("确定删除自定义图片?(此操作不可撤销)")) {
game.deleteDB("image", "control_style");
button.style.backgroundImage = "none";
button.className = "button character controlbutton dashedmenubutton";
node.classList.remove("showdelete");
if (lib.config.control_style == "custom") {
lib.configMenu.appearence.config.control_style.onclick("default");
switcher.lastChild.innerHTML = "默认";
}
button.classList.add("transparent");
}
});
},
visualMenu(node, link, name, config) {
node.className = "button character controlbutton";
node.style.backgroundSize = "";
switch (link) {
case "default": case "custom": {
node.style.backgroundImage = "none";
node.classList.add("dashedmenubutton");
break;
}
case "wood": node.setBackgroundImage("theme/woodden/wood.jpg"); break;
case "music": node.style.backgroundImage = "linear-gradient(#4b4b4b, #464646)"; break;
case "simple": node.style.backgroundImage = "linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4))"; break;
}
if (link == "custom") {
node.classList.add("transparent");
game.getDB("image", "control_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
node.style.backgroundImage = "url(" + data + ")";
node.className = "button character controlbutton";
node.parentNode.lastChild.classList.add("showdelete");
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
onclick(layout) {
game.saveConfig("control_style", layout);
if (ui.css.control_stylesheet) {
ui.css.control_stylesheet.remove();
delete ui.css.control_stylesheet;
}
if (layout == "custom") {
game.getDB("image", "control_style", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.control_stylesheet) {
ui.css.control_stylesheet.remove();
}
ui.css.control_stylesheet = lib.init.sheet(`#window .control,.menubutton:not(.active):not(.highlight):not(.red):not(.blue),#window #system>div>div{background-image:url("${fileLoadedEvent.target.result}")}`);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
else if (layout != "default") {
var str = "";
switch (layout) {
case "wood": str = `url("${lib.assetURL}theme/woodden/wood.jpg")`; break;
case "music": str = "linear-gradient(#4b4b4b, #464646);color:white;text-shadow:black 0 0 2px"; break;
case "simple": str = "linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4));color:white;text-shadow:black 0 0 2px"; break;
}
if (layout == "wood") {
ui.css.control_stylesheet = lib.init.sheet("#window .control,#window .menubutton,#window #system>div>div,#window #system>div>.pressdown2{background-image:" + str + "}");
}
else {
ui.css.control_stylesheet = lib.init.sheet("#window .control,.menubutton:not(.active):not(.highlight):not(.red):not(.blue),#window #system>div>div{background-image:" + str + "}");
}
}
},
unfrequent: true
};

View File

@ -1,7 +0,0 @@
export const ITEM = {
wood: "木纹",
music: "音乐",
simple: "简约",
custom: "自定",
default: "默认"
};

View File

@ -1,18 +0,0 @@
import { ITEM } from "./cursor-style/item.js";
export const CURSOR_STYLE = {
name: "鼠标指针",
init: "auto",
intro: "设置为固定后鼠标指针将不随移动到的区域而变化",
unfrequent: true,
item: ITEM,
onclick(item) {
game.saveConfig("cursor_style", item);
if (item == "pointer") {
ui.window.classList.add("nopointer");
}
else {
ui.window.classList.remove("nopointer");
}
}
};

View File

@ -1,4 +0,0 @@
export const ITEM = {
auto: "自动",
pointer: "固定"
};

View File

@ -1,12 +0,0 @@
import { CUSTOM_BUTTON_ITEM } from "./custom-button-item.js";
export const CUSTOM_BUTTON_CONTROL_BOTTOM = {
name: "技能下部高度",
init: "0x",
item: CUSTOM_BUTTON_ITEM,
unfrequent: true,
onclick(item) {
game.saveConfig("custom_button_control_bottom", item);
lib.configMenu.appearence.config.custom_button.onclick("skip");
}
};

View File

@ -1,12 +0,0 @@
import { CUSTOM_BUTTON_ITEM } from "./custom-button-item.js";
export const CUSTOM_BUTTON_CONTROL_TOP = {
name: "技能上部高度",
init: "0x",
item: CUSTOM_BUTTON_ITEM,
unfrequent: true,
onclick(item) {
game.saveConfig("custom_button_control_top", item);
lib.configMenu.appearence.config.custom_button.onclick("skip");
}
};

View File

@ -1,13 +0,0 @@
export const CUSTOM_BUTTON_ITEM = {
"-5x": "-5px",
"-4x": "-4px",
"-3x": "-3px",
"-2x": "-2px",
"-1x": "-1px",
"0x": "默认",
"1x": "1px",
"2x": "2px",
"3x": "3px",
"4x": "4px",
"5x": "5px"
};

View File

@ -1,12 +0,0 @@
import { CUSTOM_BUTTON_ITEM } from "./custom-button-item.js";
export const CUSTOM_BUTTON_SYSTEM_BOTTOM = {
name: "菜单下部高度",
init: "0x",
item: CUSTOM_BUTTON_ITEM,
unfrequent: true,
onclick(item) {
game.saveConfig("custom_button_system_bottom", item);
lib.configMenu.appearence.config.custom_button.onclick("skip");
}
};

View File

@ -1,12 +0,0 @@
import { CUSTOM_BUTTON_ITEM } from "./custom-button-item.js";
export const CUSTOM_BUTTON_SYSTEM_TOP = {
name: "菜单上部高度",
init: "0x",
item: CUSTOM_BUTTON_ITEM,
unfrequent: true,
onclick(item) {
game.saveConfig("custom_button_system_top", item);
lib.configMenu.appearence.config.custom_button.onclick("skip");
}
};

View File

@ -1,34 +0,0 @@
export const CUSTOM_BUTTON = {
name: "自定义按钮高度",
init: false,
unfrequent: true,
onclick(bool) {
if (bool !== "skip") {
game.saveConfig("custom_button", bool);
}
if (ui.css.buttonsheet) {
ui.css.buttonsheet.remove();
}
if (lib.config.custom_button) {
var cbnum1 = 6 + (parseInt(lib.config.custom_button_system_top) || 0);
var cbnum2 = 6 + (parseInt(lib.config.custom_button_system_bottom) || 0);
var cbnum3 = 3 + (parseInt(lib.config.custom_button_control_top) || 0);
var cbnum4 = 3 + (parseInt(lib.config.custom_button_control_bottom) || 0);
var cbnum5 = 2;
var cbnum6 = 2;
if (cbnum3 < 0) {
cbnum5 += cbnum3;
cbnum3 = 0;
}
if (cbnum4 < 0) {
cbnum6 += cbnum4;
cbnum4 = 0;
}
ui.css.buttonsheet = lib.init.sheet(
"#system>div>div, .caption>div>.tdnode{padding-top:" + cbnum1 + "px !important;padding-bottom:" + cbnum2 + "px !important}",
"#control>.control>div{padding-top:" + cbnum3 + "px;padding-bottom:" + cbnum4 + "px}",
"#control>.control{padding-top:" + cbnum5 + "px;padding-bottom:" + cbnum6 + "px}"
);
}
}
};

View File

@ -1,6 +0,0 @@
export const DAMAGE_SHAKE = {
name: "伤害抖动",
intro: "角色受到伤害时的抖动效果",
init: true,
unfrequent: true
};

View File

@ -1,9 +0,0 @@
import { ITEM } from "./die-move/item.js";
export const DIE_MOVE = {
name: "阵亡效果",
intro: "阵亡后武将的显示效果",
init: "flip",
unfrequent: true,
item: ITEM
};

View File

@ -1,5 +0,0 @@
export const ITEM = {
off: "关闭",
move: "移动",
flip: "翻面"
};

View File

@ -1,5 +0,0 @@
export const FOLD_CARD = {
name: "折叠手牌",
init: true,
unfrequent: true
};

View File

@ -1,6 +0,0 @@
export const FOLD_MODE = {
name: "折叠模式菜单",
intro: "关闭后模式菜单中“更多”内的项目将直接展开",
init: true,
unfrequent: true
};

View File

@ -1,15 +0,0 @@
export const GLASS_UI = {
name: "玻璃主题",
intro: "为游戏主题打开玻璃效果(手机暂不支持)",
init: false,
unfrequent: true,
onclick(bool) {
game.saveConfig("glass_ui", bool);
if (bool) {
ui.window.classList.add("glass_ui");
}
else {
ui.window.classList.remove("glass_ui");
}
}
};

View File

@ -1,21 +0,0 @@
import { ITEM } from "./global-font/item.js";
export const GLOBAL_FONT = {
name: "界面字体",
init: "default",
unfrequent: true,
item: ITEM,
textMenu(node, link) {
if (link != "default") {
node.style.fontFamily = link;
}
else {
node.style.fontFamily = `"STHeiti","SimHei","Microsoft JhengHei","Microsoft YaHei","WenQuanYi Micro Hei","Suits",Helvetica,Arial,sans-serif`;
}
node.style.fontSize = "20px";
},
onclick(font) {
game.saveConfig("global_font", font);
lib.init.cssstyles();
}
};

View File

@ -1 +0,0 @@
export const ITEM = {};

View File

@ -1,13 +0,0 @@
import { ITEM } from "./glow-phase/item.js";
export const GLOW_PHASE = {
name: "当前回合角色高亮",
unfrequent: true,
init: "yellow",
intro: "设置当前回合角色的边框颜色",
item: ITEM,
onclick(bool) {
game.saveConfig("glow_phase", bool);
lib.init.cssstyles();
}
};

View File

@ -1,6 +0,0 @@
export const ITEM = {
none: "无",
yellow: "黄色",
green: "绿色",
purple: "紫色"
};

View File

@ -1,177 +0,0 @@
import { ITEM } from "./hp-style/item.js";
export const HP_STYLE = {
name: "体力条样式",
init: "ol",
item: ITEM,
visualBar(node, item, create, switcher) {
if (node.created) {
return;
}
var button;
for (var i = 0; i < node.parentNode.childElementCount; i++) {
if (node.parentNode.childNodes[i]._link == "custom") {
button = node.parentNode.childNodes[i];
}
}
if (!button) {
return;
}
node.created = true;
var deletepic;
ui.create.filediv(".menubutton.addbutton", "添加图片", node, function (file) {
if (file && node.currentDB) {
game.putDB("image", "hp_style" + node.currentDB, file, function () {
game.getDB("image", "hp_style" + node.currentDB, function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
button.childNodes[node.currentDB - 1].style.backgroundImage = "url(" + data + ")";
button.classList.add("shown");
node.classList.add("showdelete");
node.currentDB++;
if (node.currentDB > 4) {
node.classList.add("hideadd");
button.classList.remove("transparent");
delete node.currentDB;
}
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
});
}
}).inputNode.accept = "image/*";
deletepic = ui.create.div(".menubutton.deletebutton", "删除图片", node, function () {
if (confirm("确定删除自定义图片?(此操作不可撤销)")) {
game.deleteDB("image", "hp_style1");
game.deleteDB("image", "hp_style2");
game.deleteDB("image", "hp_style3");
game.deleteDB("image", "hp_style4");
for (var i = 0; i < button.childElementCount; i++) {
button.childNodes[i].style.backgroundImage = "none";
}
node.classList.remove("showdelete");
node.classList.remove("hideadd");
if (lib.config.hp_style == "custom") {
lib.configMenu.appearence.config.hp_style.onclick("default");
switcher.lastChild.innerHTML = "默认";
}
button.classList.add("transparent");
button.classList.remove("shown");
node.currentDB = 1;
}
});
},
visualMenu(node, link, name, config) {
node.className = "button hpbutton dashedmenubutton";
node.innerHTML = "";
for (var i = 1; i <= 4; i++) {
var div = ui.create.div(node);
if (link == "default") {
ui.create.div(div);
}
else if (link != "custom") {
div.setBackgroundImage("theme/style/hp/image/" + link + i + ".png");
}
if (i == 4) {
div.style.webkitFilter = "grayscale(1)";
}
}
if (link == "custom") {
node.classList.add("transparent");
var getDB = function (num) {
node.parentNode.lastChild.currentDB = num;
game.getDB("image", "hp_style" + num, function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
var data = fileLoadedEvent.target.result;
node.childNodes[num - 1].style.backgroundImage = "url(" + data + ")";
node.classList.add("shown");
node.parentNode.lastChild.classList.add("showdelete");
if (num < 4) {
getDB(num + 1);
}
else {
node.parentNode.lastChild.classList.add("hideadd");
node.classList.remove("transparent");
delete node.parentNode.firstChild.currentDB;
}
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
getDB(1);
}
},
onclick(layout) {
game.saveConfig("hp_style", layout);
var style = ui.css.hp_style;
ui.css.hp_style = lib.init.css(lib.assetURL + "theme/style/hp", lib.config.hp_style);
style.remove();
if (ui.css.hp_stylesheet1) {
ui.css.hp_stylesheet1.remove();
delete ui.css.hp_stylesheet1;
}
if (ui.css.hp_stylesheet2) {
ui.css.hp_stylesheet2.remove();
delete ui.css.hp_stylesheet2;
}
if (ui.css.hp_stylesheet3) {
ui.css.hp_stylesheet3.remove();
delete ui.css.hp_stylesheet3;
}
if (ui.css.hp_stylesheet4) {
ui.css.hp_stylesheet4.remove();
delete ui.css.hp_stylesheet4;
}
if (layout == "custom") {
game.getDB("image", "hp_style1", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.hp_stylesheet1) {
ui.css.hp_stylesheet1.remove();
}
ui.css.hp_stylesheet1 = lib.init.sheet(`.hp:not(.text):not(.actcount)[data-condition="high"]>div:not(.lost){background-image:url(${fileLoadedEvent.target.result})}`);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB("image", "hp_style2", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.hp_stylesheet2) {
ui.css.hp_stylesheet2.remove();
}
ui.css.hp_stylesheet2 = lib.init.sheet(`.hp:not(.text):not(.actcount)[data-condition="mid"]>div:not(.lost){background-image:url(${fileLoadedEvent.target.result})}`);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB("image", "hp_style3", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.hp_stylesheet3) {
ui.css.hp_stylesheet3.remove();
}
ui.css.hp_stylesheet3 = lib.init.sheet(`.hp:not(.text):not(.actcount)[data-condition="low"]>div:not(.lost){background-image:url(${fileLoadedEvent.target.result})}`);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB("image", "hp_style4", function (fileToLoad) {
if (!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function (fileLoadedEvent) {
if (ui.css.hp_stylesheet4) {
ui.css.hp_stylesheet4.remove();
}
ui.css.hp_stylesheet4 = lib.init.sheet(`.hp:not(.text):not(.actcount)>.lost{background-image:url(${fileLoadedEvent.target.result})}`);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
unfrequent: true
};

View File

@ -1,10 +0,0 @@
export const ITEM = {
default: "默认",
emotion: "表情",
glass: "勾玉",
round: "国战",
ol: "手杀",
xinglass: "双鱼",
xinround: "OL",
custom: "自定"
};

View File

@ -1,18 +0,0 @@
import { ITEM } from "./identity-font/item.js";
export const IDENTITY_FONT = {
name: "身份字体",
init: "huangcao",
unfrequent: true,
item: ITEM,
textMenu(node, link) {
if (link != "default") {
node.style.fontFamily = link;
}
node.style.fontSize = "20px";
},
onclick(font) {
game.saveConfig("identity_font", font);
lib.init.cssstyles();
}
};

Some files were not shown because too many files have changed in this diff Show More