diff --git a/src/extensions/koshien/index.js b/src/extensions/koshien/index.js index 6568379d5ef..689fb86ae2e 100644 --- a/src/extensions/koshien/index.js +++ b/src/extensions/koshien/index.js @@ -93,12 +93,12 @@ class KoshienClient { } // eslint-disable-next-line no-unused-vars - moveTo (x, y) { + moveTo (position) { return new Promise(resolve => resolve()); } // eslint-disable-next-line no-unused-vars - calcRoute (srcX, srcY, dstX, dstY, exceptCells, path) { + calcRoute (src, dst, exceptCells, path) { return new Promise(resolve => resolve()); } } @@ -265,15 +265,13 @@ class KoshienBlocks { blockType: BlockType.COMMAND, text: formatMessage({ id: 'koshien.getMapArea', - default: 'get map around x: [X] y: [Y]', - description: 'get map information around x, y' + default: 'get map around [POSITION]', + description: 'get map information around position' }), arguments: { - X: { - type: ArgumentType.NUMBER - }, - Y: { - type: ArgumentType.NUMBER + POSITION: { + type: ArgumentType.STRING, + defaultValue: '0:0' } }, filter: [TargetType.SPRITE] @@ -283,19 +281,13 @@ class KoshienBlocks { blockType: BlockType.REPORTER, text: formatMessage({ id: 'koshien.map', - default: 'map at x: [X] y: [Y]', - description: 'map information at x, y' + default: 'map at [POSITION]', + description: 'map information at position' }), arguments: { - X: { - type: ArgumentType.NUMBER - }, - Y: { - type: ArgumentType.NUMBER - }, - LOCATION: { + POSITION: { type: ArgumentType.STRING, - defaultValue: 'map1' + defaultValue: '0:0' } }, filter: [TargetType.SPRITE] @@ -305,15 +297,13 @@ class KoshienBlocks { blockType: BlockType.COMMAND, text: formatMessage({ id: 'koshien.moveTo', - default: 'move to x: [X] y: [Y]', - description: 'move to x, y' + default: 'move to [POSITION]', + description: 'move to position' }), arguments: { - X: { - type: ArgumentType.NUMBER - }, - Y: { - type: ArgumentType.NUMBER + POSITION: { + type: ArgumentType.STRING, + defaultValue: '0:0' } }, filter: [TargetType.SPRITE] @@ -324,21 +314,17 @@ class KoshienBlocks { text: formatMessage({ id: 'koshien.calcRoute', // eslint-disable-next-line max-len - default: 'store shortest path (begin x: [SRC_X] y: [SRC_Y] end x: [DST_X] y: [DST_Y] except list: [EXCEPT_CELLS]) to list: [RESULT]', + default: 'store shortest path (begin [SRC] end x: [DST] except list: [EXCEPT_CELLS]) to list: [RESULT]', description: 'store shortest path between two points to list' }), arguments: { - SRC_X: { - type: ArgumentType.NUMBER - }, - SRC_Y: { - type: ArgumentType.NUMBER - }, - DST_X: { - type: ArgumentType.NUMBER + SRC: { + type: ArgumentType.STRING, + defaultValue: '0:0' }, - DST_Y: { - type: ArgumentType.NUMBER + DST: { + type: ArgumentType.STRING, + defaultValue: '0:0' }, EXCEPT_CELLS: { type: ArgumentType.STRING, @@ -358,8 +344,8 @@ class KoshienBlocks { blockType: BlockType.COMMAND, text: formatMessage({ id: 'koshien.setItem', - default: 'place a [ITEM] at x: [X] y: [Y]', - description: 'place an item at x, y' + default: 'place a [ITEM] at [POSITION]', + description: 'place an item at position' }), arguments: { ITEM: { @@ -367,51 +353,42 @@ class KoshienBlocks { menu: 'itemMenu', defaultValue: KoshienItemName.DYNAMITE }, - X: { - type: ArgumentType.NUMBER - }, - Y: { - type: ArgumentType.NUMBER + POSITION: { + type: ArgumentType.STRING, + defaultValue: '0:0' } }, filter: [TargetType.SPRITE] }, { - opcode: 'loadMap', + opcode: 'mapFrom', blockType: BlockType.REPORTER, text: formatMessage({ - id: 'koshien.loadMap', - default: 'map at x: [X] y: [Y] from [LOCATION]', - description: 'load map information at x, y from location' + id: 'koshien.mapFrom', + default: 'map at [POSITION] from [MAP]', + description: 'map information at position from variable' }), arguments: { - LOCATION: { + POSITION: { type: ArgumentType.STRING, - defaultValue: 'map1' - }, - X: { - type: ArgumentType.NUMBER + defaultValue: '0:0' }, - Y: { - type: ArgumentType.NUMBER + MAP: { + type: ArgumentType.STRING, + menu: 'variableNames', + defaultValue: ' ' } }, filter: [TargetType.SPRITE] }, { - opcode: 'saveMapAll', - blockType: BlockType.COMMAND, + opcode: 'mapAll', + blockType: BlockType.REPORTER, text: formatMessage({ - id: 'koshien.saveMapAll', - default: 'save all map to [LOCATION]', - description: 'save all map information to location' + id: 'koshien.mapAll', + default: 'all map', + description: 'all map information' }), - arguments: { - LOCATION: { - type: ArgumentType.STRING, - defaultValue: 'map1' - } - }, filter: [TargetType.SPRITE] }, { @@ -420,17 +397,13 @@ class KoshienBlocks { text: formatMessage({ id: 'koshien.locateObjects', // eslint-disable-next-line max-len - default: 'store terrain and items within range (center x: [X] y: [Y] range [SQ_SIZE] terrain/items [OBJECTS]) to list: [RESULT]', + default: 'store terrain and items within range (center [POSITION] range [SQ_SIZE] terrain/items [OBJECTS]) to list: [RESULT]', description: 'store terrain and items within range to list' }), arguments: { - X: { - type: ArgumentType.NUMBER, - defaultValue: 0 - }, - Y: { - type: ArgumentType.NUMBER, - defaultValue: 0 + POSITION: { + type: ArgumentType.STRING, + defaultValue: '0:0' }, SQ_SIZE: { type: ArgumentType.NUMBER, @@ -481,15 +454,36 @@ class KoshienBlocks { filter: [TargetType.SPRITE] }, { - opcode: 'coordinateOf', + opcode: 'position', blockType: BlockType.REPORTER, text: formatMessage({ - id: 'koshien.coordinateOf', - default: '[WHERE] of [COORDINATE]', - description: 'where of coordinate' + id: 'koshien.position', + default: 'position [X] [Y]', + description: 'x and y convert to position' }), arguments: { - WHERE: { + X: { + type: ArgumentType.NUMBER, + defaultValue: 0 + }, + Y: { + type: ArgumentType.NUMBER, + defaultValue: 0 + } + + }, + filter: [TargetType.SPRITE] + }, + { + opcode: 'positionOf', + blockType: BlockType.REPORTER, + text: formatMessage({ + id: 'koshien.positionOf', + default: '[POSITION] of [COORDINATE]', + description: 'position of coordinate' + }), + arguments: { + POSITION: { type: ArgumentType.STRING, defaultValue: '0:0' }, @@ -504,6 +498,10 @@ class KoshienBlocks { } ], menus: { + variableNames: { + acceptReporters: false, + items: 'getVariableNamesMenuItems' + }, listNames: { acceptReporters: false, items: 'getListNamesMenuItems' @@ -526,9 +524,17 @@ class KoshienBlocks { }; } + getVariableNamesMenuItems () { + return this.getVariableOrListNamesMenuItems(Variable.SCALAR_TYPE); + } + getListNamesMenuItems () { + return this.getVariableOrListNamesMenuItems(Variable.LIST_TYPE); + } + + getVariableOrListNamesMenuItems (type) { const sprite = this.runtime.getEditingTarget(); - return [' '].concat(sprite.getAllVariableNamesInScopeByType(Variable.LIST_TYPE)); + return [' '].concat(sprite.getAllVariableNamesInScopeByType(type)); } /** @@ -548,10 +554,9 @@ class KoshienBlocks { } /** - * get map information around x, y + * get map information around position * @param {object} args - the block's arguments. - * @param {number} args.X - x. - * @param {number} args.Y - y. + * @param {number} args.POSITION - position */ // eslint-disable-next-line no-unused-vars getMapArea (args) { @@ -559,10 +564,9 @@ class KoshienBlocks { } /** - * map at x, y + * map at position * @param {object} args - the block's arguments. - * @param {number} args.X - x. - * @param {number} args.Y - y. + * @param {string} args.POSITION - position. * @return {number} - map information. */ // eslint-disable-next-line no-unused-vars @@ -574,70 +578,61 @@ class KoshienBlocks { /** * move to x, y * @param {object} args - the block's arguments. - * @param {number} args.X - x. - * @param {number} args.Y - y. + * @param {number} args.POSITION - position. * @return {Promise} - promise */ moveTo (args) { - return this._client.moveTo(args.X, args.Y); + return this._client.moveTo(args.POSITION); } /** * shortest path between two points * @param {object} args - the block's arguments. - * @param {number} args.SRC_X - from x. - * @param {number} args.SRC_Y - from y. - * @param {number} args.DST_X - to x. - * @param {number} args.DST_Y - to y. + * @param {string} args.SRC - src. + * @param {string} args.DST - dst. * @param {string} args.EXCEPT_CELLS - except cells. * @param {string} args.RESULT - result. * @return {Promise} - promise */ // eslint-disable-next-line no-unused-vars calcRoute (args) { - return this._client.calcRoute(args.SRC_X, args.SRC_Y, args.DST_X, args.DST_Y, args.EXCEPT_CELLS, args.PATH); + return this._client.calcRoute(args.SRC, args.DST, args.EXCEPT_CELLS, args.RESULT); } /** - * place an item at x, y + * place an item at position * @param {object} args - the block's arguments. * @param {string} args.ITEM - item. - * @param {number} args.X - x. - * @param {number} args.Y - y. - */ + * @param {string} args.POSITION - position. + */ // eslint-disable-next-line no-unused-vars setItem (args) { // wip } /** - * load map from location at x, y + * map from location at position * @param {object} args - the block's arguments. - * @param {string} args.LOCATION - location. - * @param {number} args.X - x. - * @param {number} args.Y - y. + * @param {string} args.MAP - map. + * @param {string} args.POSITION - position. * @return {number} - map information. */ // eslint-disable-next-line no-unused-vars - loadMap (args) { + mapFrom (args) { // wip return -1; } /** - * save all map information to location - * @param {object} args - the block's arguments. - * @param {string} args.LOCATION - location. + * all map information */ - // eslint-disable-next-line no-unused-vars - saveMapAll (args) { + mapAll () { // wip } /** * terrain and items within range * @param {object} args - the block's arguments. - * @param {number} args.X - x. - * @param {number} args.Y - y. + * @param {string} args.POSITION - position. * @param {number} args.SQ_SIZE - size. * @param {string} args.OBJECTS - item. * @param {string} args.RESULT - result. @@ -666,17 +661,29 @@ class KoshienBlocks { // wip } + /** + * x and y convert to position + * @param {object} args - the block's arguments. + * @param {number} args.X - x. + * @param {number} args.Y - y. + * @return {string} - position + */ + // eslint-disable-next-line no-unused-vars + position (args) { + return `${args.X}:${args.Y}`; + } + /** * where of coordinate * @param {object} args - the block's arguments. - * @param {string} args.WHERE - where. + * @param {string} args.POSITION - position. * @param {string} args.COORDINATE - coordinate. - * @return {number} - where of x or y + * @return {number} - position of x or y */ // eslint-disable-next-line no-unused-vars - coordinateOf (args) { - const where = args.WHERE.split(':'); - return Number(args.COORDINATE === 'x' ? where[0] : where[1]); + positionOf (args) { + const position = args.POSITION.split(':'); + return Number(args.COORDINATE === 'x' ? position[0] : position[1]); } } diff --git a/src/extensions/koshien/translations.json b/src/extensions/koshien/translations.json index 7e219b8d1d6..149a751e129 100644 --- a/src/extensions/koshien/translations.json +++ b/src/extensions/koshien/translations.json @@ -10,19 +10,41 @@ "koshien.coordinatesMenu.x": "x座標", "koshien.coordinatesMenu.y": "y座標", "koshien.connectGame": "プレイヤー名を [NAME] にして、ゲームサーバへ接続する", - "koshien.getMapArea": "x座標が [X] 、y座標が [Y] 付近のマップ情報を取得する", - "koshien.map": "x座標が [X] y座標が [Y] のマップ情報", - "koshien.moveTo": "x座標 [X]、y座標 [Y] に移動する", - "koshien.calcRoute": "2点間の最短経路 (始点 x座標 [SRC_X] y座標 [SRC_Y] 、終点 x座標 [DST_X] y座標 [DST_Y] 、通らない座標 リスト [EXCEPT_CELLS]) をリスト [RESULT] に保存する", - "koshien.setItem": "[ITEM] をx座標 [X] y座標 [Y] に置く", - "koshien.loadMap": "x座標が [X] y座標が [Y] のマップ情報を [LOCATION] から読み込む", - "koshien.saveMapAll": "すべてのマップ情報を [LOCATION] に保存する", - "koshien.locateObjects": "範囲内の地形・アイテム (中心 x座標 [X] y座標 [Y] 、範囲 [SQ_SIZE] 、地形・アイテム [OBJECTS])をリスト [RESULT] に保存する", + "koshien.getMapArea": "座標 [POSITION] 付近のマップ情報を取得する", + "koshien.map": "座標 [POSITION] のマップ情報", + "koshien.moveTo": "座標 [POSITION] に移動する", + "koshien.calcRoute": "最短経路 (始点 座標 [SRC] 終点 座標 [DST] 、通らない座標 リスト [EXCEPT_CELLS]) をリスト [RESULT] に保存する", + "koshien.setItem": "[ITEM] を座標 [POSITION] に置く", + "koshien.mapFrom": "座標 [POSITION] のマップ情報を変数 [MAP] から読み込む", + "koshien.mapAll": "すべてのマップ情報", + "koshien.locateObjects": "範囲内の地形・アイテム (中心 座標 [POSITION] 、範囲 [SQ_SIZE] 、地形・アイテム [OBJECTS])をリスト [RESULT] に保存する", "koshien.targetCoordinate": "[TARGET] の [COORDINATE]", "koshien.turnOver": "ターンを終了する", - "koshien.coordinateOf": "[WHERE] の [COORDINATE]" + "koshien.position": "座標 [X] [Y]", + "koshien.positionOf": "[POSITION] の [COORDINATE]" }, "ja-Hira": { - "koshien.name": "こうしえん" + "koshien.name": "こうしえん", + "koshien.itemsMenu.dynamite": "ダイナマイト", + "koshien.itemsMenu.bomb": "ばくだん", + "koshien.targetsMenu.other": "たいせんキャラクター", + "koshien.targetsMenu.enemy": "ぼうがいキャラクター", + "koshien.targetsMenu.goal": "ゴール", + "koshien.targetsMenu.player": "プレイヤー", + "koshien.coordinatesMenu.x": "xざひょう", + "koshien.coordinatesMenu.y": "yざひょう", + "koshien.connectGame": "プレイヤーめいを [NAME] にして、ゲームサーバへせつぞくする", + "koshien.getMapArea": "ざひょう [POSITION] ふきんのマップじょうほうをしゅとくする", + "koshien.map": "ざひょう [POSITION] のマップじょうほう", + "koshien.moveTo": "ざひょう [POSITION] にいどうする", + "koshien.calcRoute": "さいたんけいろ (してん ざひょう [SRC_POSITION] しゅうてん ざひょう [DST_POSITION] 、とおらないざひょう リスト [EXCEPT_CELLS]) をリスト [RESULT] にほぞんする", + "koshien.setItem": "[ITEM] をざひょう [POSITION] におく", + "koshien.mapFrom": "ざひょう [POSITION] のマップじょうほうをへんすう [MAP] からよみこむ", + "koshien.mapAll": "すべてのマップじょうほう", + "koshien.locateObjects": "はんいないのちけい・アイテム (ちゅうしん ざひょう [POSITION] 、はんい [SQ_SIZE] 、ちけい・アイテム [OBJECTS])をリスト [RESULT] にほぞんする", + "koshien.targetCoordinate": "[TARGET] の [COORDINATE]", + "koshien.turnOver": "ターンをしゅうりょうする", + "koshien.position": "ざひょう [X] [Y]", + "koshien.positionOf": "[POSITION] の [COORDINATE]" } }