Browse Source

想重构版面预览,挺麻烦的。

tags/v26.0
枫谷剑仙 3 years ago
parent
commit
9bec247943
3 changed files with 80 additions and 20 deletions
  1. +9
    -0
      languages/zh.js
  2. +9
    -1
      script-json_data.js
  3. +62
    -19
      script-skill-parser.js

+ 9
- 0
languages/zh.js View File

@@ -98,6 +98,7 @@
obstruct_opponent_before_me: tp`排名比自身高的对手`,
obstruct_opponent_designated_position: tp`第${'positions'}排位的对手`,
increase_damage_cap: tp`${'targets'}的${'icon'}伤害上限提升到${'cap'}`,
board_jamming_state: tp`在${'position'}生成${'state'}${'size'}${'count'}${'time'}`,
},
power: {
unknown: tp`[ 未知能力提升: ${'type'} ]`,
@@ -145,6 +146,7 @@
bottom: tp`下方第${'pos'}横行`,
left: tp`左方第${'pos'}竖列`,
right: tp`右方第${'pos'}竖列`,
random: tp`随机位置`,
shape: tp`指定位置`,
},
value: {
@@ -159,6 +161,8 @@
random_atk: tp`${'atk'}×${'min'}${'max'}倍`,
prob: tp`有${'value'}几率`,
x_awakenings: tp`${'awakenings'}数量×${'value'}`,
size: tp`${'width'}×${'height'}`,
pos: tp`${'x'}×${'y'}`,
},
target: {
unknown: tp`未知目标`,
@@ -240,6 +244,11 @@
all: tp`所有`,
any: tp`任何${'cotent'}`,
},
board: {
cloud: tp`${'icon'}云`,
roulette: tp`${'icon'}轮盘位`,
roulette_time: tp`(每${'duration'}变换)`,
},
types: {
[0]: tp`${'icon'}进化用`,
[1]: tp`${'icon'}平衡`,


+ 9
- 1
script-json_data.js View File

@@ -114,6 +114,7 @@ let localTranslating = {
obstruct_opponent_before_me: tp`The opponent ranked higher than me`,
obstruct_opponent_designated_position: tp`No.${'positions'} ranked opponents`,
increase_damage_cap: tp`The ${'icon'}damage cap of ${'targets'} is increased to ${'cap'}`,
board_jamming_state: tp`Creates ${'count'} ${'state'} ${'size'} at ${'position'}${'time'}`,
},
power: {
unknown: tp`[ Unkonwn power up: ${'type'} ]`,
@@ -161,6 +162,7 @@ let localTranslating = {
bottom: tp`${'pos'} of bottom rows`,
left: tp`${'pos'} of left columns`,
right: tp`${'pos'} of right columns`,
random: tp`random location`,
shape: tp`specified location`,
},
value: {
@@ -175,6 +177,8 @@ let localTranslating = {
random_atk: tp`${'atk'} ×${'min'}${'max'}`,
prob: tp`${'value'} chance for `,
x_awakenings: tp`count of ${'awakenings'} ×${'value'}`,
size: tp`${'width'}×${'height'}`,
pos: tp`${'x'}×${'y'}`,
},
target: {
unknown: tp`Unkown Target`,
@@ -250,12 +254,16 @@ let localTranslating = {
enhanced: tp`${'icon'}Enhanced`,
locked: tp`${'icon'}Locked`,
nail: tp`${'icon'}Nail`,
variation: tp`${'icon'}Roulette (transforms every ${'time'})`,
_5color: tp`${'icon'}5 Att.`,
_6color: tp`${'_5color'}+${'orb_rcv'}`,
all: tp`All`,
any: tp`Any ${'cotent'}`,
},
board: {
cloud: tp`${'icon'}Cloud`,
roulette: tp`${'icon'}Roulette`,
roulette_time: tp`(transforms every ${'duration'})`,
},
types: {
[0]: tp`${'icon'}Evo Material`,
[1]: tp`${'icon'}Balanced`,


+ 62
- 19
script-skill-parser.js View File

@@ -104,6 +104,8 @@ class Orb
locked = false; //锁定
bound = false;
variation = false; //随机变换
roulette = false; //轮盘位
cloud = false; //云
constructor(color)
{
this.color = color;
@@ -117,6 +119,7 @@ class Board
rowCount = 6;
columnCount = 7;
data = [];
state = [];
constructor(def = null)
{
for (let ri=0;ri<this.rowCount;ri++)
@@ -199,7 +202,7 @@ class Board
return randomData;
}
//洗版的填充
randomFill(attrs)
randomFill(attrs, states)
{
let valueArray = new Uint8Array(this.rowCount * this.columnCount);
crypto.getRandomValues(valueArray); //获取符合密码学要求的安全的随机值
@@ -213,7 +216,7 @@ class Board
this.sequenceFill(randomData);
}
//生成珠子的填充
generateOrbs(attrs, count, exclude)
generateOrbs(attrs, count, exclude, states)
{
let space = this.rowCount * this.columnCount;
if (exclude?.length > 0)
@@ -221,7 +224,7 @@ class Board
space -= this.data.flat().filter(o=>exclude.includes(o)).length;
}
let valueArray = new Array(space);
const valueArray = new Array(space);
attrs.forEach((attr,idx)=>{
valueArray.fill(attr, idx * count, (idx + 1) * count);
});
@@ -230,7 +233,7 @@ class Board
this.sequenceFill(randomData, exclude);
}
//设定横行
setRow(rowsNumber, attr = 0)
setRow(rowsNumber, attr = 0, states)
{
for (let row of rowsNumber)
{
@@ -243,7 +246,7 @@ class Board
}
}
//设定竖列
setColumn(colsNumber, attr = 0)
setColumn(colsNumber, attr = 0, states)
{
for (let col of colsNumber)
{
@@ -255,7 +258,7 @@ class Board
}
}
//设定形状
setShape(matrix, attr = 0)
setShape(matrix, attr = 0, states)
{
function fillRow(rowData, inputRow, attr)
{
@@ -418,6 +421,7 @@ const SkillKinds = {
ImpartAwakenings: "impart-awakenings",
ObstructOpponent: "obstruct-opponent",
IncreaseDamageCap: "increase-damage-cap",
BoardJammingStates: "board-jamming-states",
}
function skillParser(skillId)
@@ -873,14 +877,14 @@ function autoHealBuff(value) {
function fromTo(from, to) {
return { from: from, to: to };
}
function changeOrbs() {
return { kind: SkillKinds.ChangeOrbs, changes: Array.from(arguments) };
function changeOrbs(...changes) {
return { kind: SkillKinds.ChangeOrbs, changes: changes };
}
function generateOrbs(orbs, exclude, count, time) {
return { kind: SkillKinds.GenerateOrbs, orbs: orbs, exclude: exclude, count: count, time: time};
}
function fixedOrbs() {
return { kind: SkillKinds.FixedOrbs, generates: Array.from(arguments) };
function fixedOrbs(...generates) {
return { kind: SkillKinds.FixedOrbs, generates: generates };
}
function powerUp(attrs, types, value, condition = null, reduceDamageValue = null, additional = []) {
if (value.kind === SkillPowerUpKind.Multiplier) {
@@ -962,12 +966,15 @@ function skillProviso(cond) { return { kind: SkillKinds.SkillProviso, cond: cond
function impartAwakenings(attrs, types, awakenings) {
return { kind: SkillKinds.ImpartAwakenings, attrs: attrs, types: types, awakenings: awakenings };
}
function obstructOpponent(type, pos, ids) {
return { kind: SkillKinds.ObstructOpponent, type: type, pos: pos, enemy_skills: ids };
function obstructOpponent(typeName, pos, ids) {
return { kind: SkillKinds.ObstructOpponent, typeName: typeName, pos: pos, enemy_skills: ids };
}
function increaseDamageCap(cap, targets) {
return { kind: SkillKinds.IncreaseDamageCap, cap: cap, targets: targets};
}
function boardJammingStates(state, posType, options) {
return { kind: SkillKinds.BoardJammingStates, state: state, posType: posType, ...options};
}
const parsers = {
parser: (() => []), //这个用来解决代码提示的报错问题,不起实际作用
@@ -1406,10 +1413,20 @@ const parsers = {
return powerUp(null, null, p.scaleMatchAttrs(attrs.flatMap(flags), min, min, [100, 100], [0, 0]), null, null, combo ? [addCombo(combo)] : null);
},
[207](turns, time, row1, row2, row3, row4, row5, count) {
return activeTurns(turns, count ?
/*return activeTurns(turns, count ?
generateOrbs( ['variation'], null, count, time/100):
fixedOrbs( { orbs: ['variation'], time: time/100, type: 'shape', positions: [row1, row2, row3, row4, row5].map(row=>flags(row)) })
);
);*/
const options = { time: time/100};
if (count) {
options.count = count;
} else {
options.positions = [row1, row2, row3, row4, row5].map(flags);
}
return activeTurns(turns,
boardJammingStates('roulette', count ? 'random' : 'shape',
{ time: time/100 , count: count, positions: [row1, row2, row3, row4, row5].map(flags) }
));
},
[208](count1, to1, exclude1, count2, to2, exclude2) {
return [
@@ -1482,6 +1499,11 @@ const parsers = {
powerUp(null, null, p.mul({ hp: hp }))
);
},
[238](turns, width, height, pos1, pos2) { //产云
return activeTurns(turns,
boardJammingStates('cloud', (pos1 && pos2) ? 'fixed' : 'random', { size: [width, height], positions: [pos1, pos2] })
);
},
[241](turns, cap, target = 1) { //改变伤害上限
const targetTypes = ["self","leader-self","leader-helper","sub-members"];
const typeArr = flags(target).map(n => targetTypes[n]);
@@ -2083,14 +2105,14 @@ function renderSkill(skill, option = {})
}
for (const generate of generates)
{
let orb = generate.orbs?.[0], time = generate.time;
let variationorb = generate.orbs?.[0], time = generate.time;
dict = {
orbs: renderOrbs(orb, {time}),
};
if (generate.type == 'shape')
{
dict.position = tsp.position.shape();
if (!merge_skill) board.setShape(generate.positions, orb);
if (board) board.setShape(generate.positions, orb);
}else
{
let posFrgs = [];
@@ -2100,20 +2122,20 @@ function renderSkill(skill, option = {})
const pos = posSplit(generate.positions, 5);
if (pos.sequence.length) posFrgs.push(tsp.position.top({pos: pos.sequence.join(slight_pause)}));
if (pos.reverse.length) posFrgs.push(tsp.position.bottom({pos: pos.reverse.join(slight_pause)}));
if (!merge_skill) board.setRow(generate.positions, orb);
if (board) board.setRow(generate.positions, orb);
}else
{
const pos = posSplit(generate.positions, 6);
if (pos.sequence.length) posFrgs.push(tsp.position.left({pos: pos.sequence.join(slight_pause)}));
if (pos.reverse.length) posFrgs.push(tsp.position.right({pos: pos.reverse.join(slight_pause)}));
if (!merge_skill) board.setColumn(generate.positions, orb);
if (board) board.setColumn(generate.positions, orb);
}
dict.position = posFrgs.nodeJoin(tsp.word.slight_pause());
}
subDocument.push(tsp.skill.fixed_orbs(dict));
}
frg.ap(subDocument.nodeJoin(tsp.word.comma()));
if (!merge_skill) frg.ap(board.toTable());
if (board) frg.ap(board.toTable());
break;
}
@@ -2368,6 +2390,27 @@ function renderSkill(skill, option = {})
frg.ap(tsp.skill.increase_damage_cap(dict));
break;
}
case SkillKinds.BoardJammingStates: { //版面产生干扰状态
const { state, posType, size, positions, count, time } = skill;
let board = merge_skill ? null : new Board();
dict = {
state: tsp.board[state](),
position: posType == 'random' ? tsp.position.random() : tsp.position.shape(),
};
if (state == 'roulette') { //轮盘位
dict.time = tsp.board.roulette_time({duration: renderValue(v.constant(time), {unit: tsp.unit.seconds})});
dict.count = renderValue(v.constant(count || positions.flat().length), {unit: tsp.unit.orbs});
}
if (state == 'cloud') { //云
const [width, height] = size;
dict.size = tsp.value.size({ width: width, height: height});
}
frg.ap(tsp.skill.board_jamming_state(dict));
if (board) frg.ap(board.toTable());
break;
}
default: {
console.log("未处理的技能类型",skill.kind, skill);


Loading…
Cancel
Save