插件结构改造

This commit is contained in:
AncTe committed 2023-02-28 17:49:34 +08:00
1 parent 8ab10d5612
commit 023d913ea7
53 files changed
+9640 -9816

No files matched your search

+7 -5
View File
@@ -51,17 +51,19 @@
"<br>",
"游戏版本:V1.0.0",
"<br>",
"游戏作者:古祠",
"<br>",
"游戏开源地址:<a href=\"https://github.com/unanmed/HumanBreak\" target=\"_blank\">",
"https://github.com/unanmed/HumanBreak</a>",
"<br>",
"游戏作者:古祠",
"<br>",
"本塔遵循MIT开源协议。<a href=\"LICENSE\" target=\"_blank\">查看开源协议</a>",
"<br>",
"BGM来源:网易云音乐等",
"音乐来源:网易云音乐等",
"<br>",
"素材来源:大素材库、爱给网、网站素材库等",
"<br>",
"<span style=\"color: gold\">特别说明:素材与音乐均来自网络,不得用于商业用途,仅用于参考与学习</span>",
"<br>",
"特别鸣谢:无名甲烷菌(提供部分特殊属性与机制想法)",
"<br>",
"测试:"
@@ -450,14 +452,14 @@
},
"study": {
"text": "学习",
"condition": "core.getSkillLevel(11) > 0",
"condition": "core.plugin.skillTree.getSkillLevel(11) > 0",
"desc": [
"本条目会详细说明学习的机制与所有可以被学习的技能被学习后的效果。当前已经学习的技能会以与状态栏类似的盒子展示出来。",
"<br>",
"<br>",
"首先,学习技能消耗的智慧点会越来越多,初始消耗的智慧点为500,每学习一次增加250。",
"学习的技能可以持续5场战斗,在技能树界面每升级一次增加3场,",
"<span style=\"color: gold\">当前为${core.getSkillLevel(11) * 3 + 2}场</span>。",
"<span style=\"color: gold\">当前为${core.plugin.skillTree.getSkillLevel(11) * 3 + 2}场</span>。",
"学习后对应属性的值,例如抱团怪增加的属性百分比,会与被学习的怪物相同。学习界面可以使用背包中的道具或点击状态栏打开。",
"<br>",
"<br>",
+2 -2
View File
@@ -8,7 +8,7 @@
},
"blade": {
"text": "1:断灭之刃",
"opened": "core.getSkillLevel(2) > 0",
"opened": "core.plugin.skillTree.getSkillLevel(2) > 0",
"desc": [
"<span style=\"color: gold\">快捷键1</span>,开启后勇士攻击增加${level:2 * 10}%,",
"同时防御减少${level:2 * 10}%。",
@@ -31,7 +31,7 @@
},
"shield": {
"text": "3:铸剑为盾",
"opened": "core.getSkillLevel(10) > 0",
"opened": "core.plugin.skillTree.getSkillLevel(10) > 0",
"desc": [
"<span style=\"color: gold\">快捷键3</span>,开启后勇士防御增加${level:10 * 10}%,",
"同时攻击减少${level:10 * 10}%。",
+1 -1
View File
@@ -576,7 +576,7 @@ export function para3(chase: Chase) {
'MT14',
async () => {
flags.finishChase1 = true;
core.autoFixRouteBoss();
core.plugin.towerBoss.autoFixRouteBoss();
core.showStatusBar();
ani.time(750).apply('rect', 0);
chase.end();
+3 -2
View File
@@ -105,16 +105,17 @@ function resetFlag() {
}
export async function triggerFullscreen() {
const { maxGameScale } = core.plugin.utils;
if (document.fullscreenElement) {
await document.exitFullscreen();
requestAnimationFrame(() => {
core.maxGameScale(1);
maxGameScale(1);
});
fullscreen.value = false;
} else {
await document.body.requestFullscreen();
requestAnimationFrame(() => {
core.maxGameScale();
maxGameScale();
});
fullscreen.value = true;
}
+2
View File
@@ -68,6 +68,8 @@ interface MainData {
* 图片切分信息
*/
readonly splitImages: SplitImageData;
readonly plugin: string[];
}
interface FirstData {
+54 -38
View File
@@ -18,10 +18,20 @@ interface PluginDeclaration
extends PluginUtils,
PluginUis,
PluginUse,
SkillTree,
MiniMap,
HeroRealStatus,
PluginAchievement {
/**
*
*/
utils: GamePluginUtils;
loopMap: GamePluginLoopMap;
towerBoss: GamePluginBoss;
skillTree: GamePluginSkillTree;
study: GamePluginStudy;
hero: GamePluginHeroRealStatus;
skills: Record<Chapter, Skill[]>;
/**
* 添加函数 例:添加弹出文字,像这个就可以使用core.addPop或core.plugin.addPop调用
* @param px 弹出的横坐标
@@ -83,6 +93,45 @@ interface PluginDeclaration
resetFlagSettings(): void;
}
interface GamePluginUtils {
/**
* 判定一个值是否不是undefined或null
* @param value 要判断的值
*/
has<T>(value: T): value is NonNullable<T>;
/**
* 滑动数组
* @param arr 数组
* @param delta 偏移量,正数表示向右滑动,负数表示向左滑动
*/
slide<T>(arr: T[], delta: number): T[];
/**
* 获取方向的反方向
* @param dir 方向
*/
backDir(dir: Dir): Dir;
/**
* 最大化游戏缩放
* @param n 最大缩放再少多少个缩放
*/
maxGameScale(n?: number): void;
}
interface GamePluginLoopMap {
checkLoopMap(): void;
}
interface GamePluginBoss {
/**
* 自动修复特殊boss战的录像
* @param isStart 是否要开始修剪录像
*/
autoFixRouteBoss(isStart?: boolean);
}
interface PluginUtils {
/**
* 判定一个值是否不是undefined或null
@@ -116,37 +165,6 @@ interface PluginUtils {
* @param index 追逐战索引
*/
startChase(index: number): Promise<void>;
/**
* 自动修复特殊boss战的录像
* @param isStart 是否要开始修剪录像
*/
autoFixRouteBoss(isStart?: boolean);
/**
* 滑动数组
* @param arr 数组
* @param delta 偏移量,正数表示向右滑动,负数表示向左滑动
*/
slide<T>(arr: T[], delta: number): T[];
/**
* 获取方向的反方向
* @param dir 方向
*/
backDir(dir: Dir): Dir;
/**
* 判断一个值是否不是undefined和null
* @param value 要判断的值
*/
has<T>(value: T): value is NonNullable<T>;
/**
* 最大化游戏缩放
* @param n 最大缩放再少多少个缩放
*/
maxGameScale(n?: number): void;
}
interface PluginUis {
@@ -277,9 +295,7 @@ interface PluginUse {
useUp(ele: HTMLElement, fn: DragFn): void;
}
interface SkillTree {
skills: Record<Chapter, Skill[]>;
interface GamePluginSkillTree {
/**
* 获取技能等级
* @param skill 技能索引
@@ -323,7 +339,7 @@ interface MiniMap {
splitArea(): void;
}
interface Study {
interface GamePluginStudy {
/**
* 学习一个怪物技能
* @param enemy 被学习的怪物
@@ -332,7 +348,7 @@ interface Study {
studySkill(enemy: Enemy, num: number): void;
}
interface HeroRealStatus {
interface GamePluginHeroRealStatus {
/**
* 获取勇士在某一点的属性
* @param name 要获取的勇士属性
+1 -1
View File
@@ -77,7 +77,7 @@
<span
class="selectable"
:selected="selected === 'showStudied'"
v-if="core.getSkillLevel(11) > 0"
v-if="core.plugin.skillTree.getSkillLevel(11) > 0"
@click="click('showStudied')"
>展示已学习技能:&nbsp;&nbsp;&nbsp;{{
showStudied ? 'ON' : 'OFF'
+4 -1
View File
@@ -51,7 +51,10 @@ const content = computed(() => {
} else return v;
})
.join('')
.replace(/level:(\d+)/g, 'core.getSkillLevel($1)') +
.replace(
/level:(\d+)/g,
'core.plugin.skillTree.getSkillLevel($1)'
) +
'`'
);
});
+16 -14
View File
@@ -108,7 +108,7 @@ const mdef = ref(core.status.hero.mdef);
const skill = computed(() => {
update.value;
return core.getSkillFromIndex(selected.value);
return core.plugin.skillTree.getSkillFromIndex(selected.value);
});
const skills = computed(() => {
@@ -119,8 +119,9 @@ const desc = computed(() => {
return eval(
'`' +
splitText(skill.value.desc).replace(/level(:\d+)?/g, (str, $1) => {
if ($1) return `core.getSkillLevel(${$1})`;
else return `core.getSkillLevel(${skill.value.index})`;
if ($1) return `core.plugin.skillTree.getSkillLevel(${$1})`;
else
return `core.plugin.skillTree.getSkillLevel(${skill.value.index})`;
}) +
'`'
);
@@ -134,9 +135,10 @@ const effect = computed(() => {
skill.value.effect
.join('')
.replace(/level(:\d+)?/g, (str, $1) => {
if ($1) return `(core.getSkillLevel(${$1}) + ${v})`;
if ($1)
return `(core.plugin.skillTree.getSkillLevel(${$1}) + ${v})`;
else
return `(core.getSkillLevel(${skill.value.index}) + ${v})`;
return `(core.plugin.skillTree.getSkillLevel(${skill.value.index}) + ${v})`;
}) +
'`'
);
@@ -154,20 +156,20 @@ const dict = computed(() => {
const front = computed(() => {
return skill.value.front.map(v => {
return `${core.getSkillLevel(v[0]) >= v[1] ? 'a' : 'b'}${v[1]}级 ${
skills.value[dict.value[v[0]]].title
}`;
return `${
core.plugin.skillTree.getSkillLevel(v[0]) >= v[1] ? 'a' : 'b'
}${v[1]}级 ${skills.value[dict.value[v[0]]].title}`;
});
});
const consume = computed(() => {
update.value;
return core.getSkillConsume(selected.value);
return core.plugin.skillTree.getSkillConsume(selected.value);
});
const level = computed(() => {
update.value;
return core.getSkillLevel(selected.value);
return core.plugin.skillTree.getSkillLevel(selected.value);
});
function exit() {
@@ -195,9 +197,9 @@ function draw() {
ctx.lineTo(
...(s.loc.map(v => (v * 2 - 1) * per + per / 2) as LocArr)
);
if (core.getSkillLevel(s.index) < v.front[i][1])
if (core.plugin.skillTree.getSkillLevel(s.index) < v.front[i][1])
ctx.strokeStyle = '#aaa';
else if (core.getSkillLevel(s.index) === s.max)
else if (core.plugin.skillTree.getSkillLevel(s.index) === s.max)
ctx.strokeStyle = '#ff0';
else ctx.strokeStyle = '#0f8';
ctx.lineWidth = devicePixelRatio;
@@ -206,7 +208,7 @@ function draw() {
});
skills.value.forEach(v => {
const [x, y] = v.loc.map(v => v * 2 - 1);
const level = core.getSkillLevel(v.index);
const level = core.plugin.skillTree.getSkillLevel(v.index);
// 技能图标
ctx.save();
ctx.lineWidth = per * 0.06;
@@ -247,7 +249,7 @@ function click(e: MouseEvent) {
}
function upgrade(index: number) {
const success = core.upgradeSkill(index);
const success = core.plugin.skillTree.upgradeSkill(index);
if (!success) tip('error', '升级失败!');
else {
tip('success', '升级成功!');
+2 -2
View File
@@ -149,7 +149,7 @@ const skill = ref<string>('无');
const up = ref(0);
const spring = ref<number>();
const skillOpened = ref(core.getFlag('chapter', 0) > 0);
const studyOpened = ref(core.getSkillLevel(11) > 0);
const studyOpened = ref(core.plugin.skillTree.getSkillLevel(11) > 0);
/**
* 要展示的勇士属性
*/
@@ -191,7 +191,7 @@ function update() {
spring.value = 50 - flags.springCount;
}
skillOpened.value = core.getFlag('chapter', 0) > 0;
studyOpened.value = core.getSkillLevel(11) > 0;
studyOpened.value = core.plugin.skillTree.getSkillLevel(11) > 0;
}
function openSkillTree() {