forked from scratchfoundation/scratch-gui
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #355 from smalruby/speak-mentaiko-kousien
Speak mentaiko kousien
- Loading branch information
Showing
13 changed files
with
612 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"koshien.connect_game": { | ||
"snippet": "koshien.connect_game(name: ${1:\"player1\"})", | ||
"description": "プレイヤー名を (player1) にして、ゲームサーバへ接続する" | ||
}, | ||
"koshien.move_to": { | ||
"snippet": "koshien.move_to(${1:0}, ${2:0})", | ||
"description": "x座標 (0)、y座標 (0) に移動する" | ||
}, | ||
"koshien.get_map_area": { | ||
"snippet": "koshien.get_map_area(${1:0}, ${2:0})", | ||
"description": "x座標が (0) 、y座標が (0) 付近のマップ情報を取得する" | ||
}, | ||
"koshien.map": { | ||
"snippet": "koshien.map(${1:0}, ${2:0})", | ||
"description": "x座標が (0) 、y座標が (0) のマップ情報" | ||
}, | ||
"koshien.calc_route": { | ||
"snippet": "koshien.calc_route(src: [${1:0}, ${2:0}], dst: [${3:0}, ${4:0}], except_cells: ${5:\"通らない座標\"}, result: ${6:\"最短経路\"})", | ||
"description": "2点間の最短経路 始点 x座標 (0) y座標 (0) 終点 x座標 (0) y座標 (0) 通らない座標 リスト (通らない座標) をリスト (最短経路) に保存する" | ||
}, | ||
"koshien.set_dynamite": { | ||
"snippet": "koshien.set_dynamite([${1:0},${2:0}])", | ||
"description": "ダイナマイトをx座標 (0) y座標 (0) に置く" | ||
}, | ||
"koshien.set_bomb": { | ||
"snippet": "koshien.set_bomb([${1:0},${2:0}])", | ||
"description": "爆弾をx座標 (0) y座標 (0) に置く" | ||
}, | ||
"koshien.save_map_all": { | ||
"snippet": "koshien.save_map_all(${1:\"map1\"})", | ||
"description": "すべてのマップ情報を (map1) に保存する" | ||
}, | ||
"koshien.load_map": { | ||
"snippet": "koshien.load_map(${1:\"map1\"}, ${2:0}, ${3:0})", | ||
"description": "x座標が (0) 、y座標が (0) のマップ情報を (map1) から読み込む" | ||
}, | ||
"koshien.other_player_x": { | ||
"snippet": "koshien.other_player_x", | ||
"description": "対戦キャラクタの x座標" | ||
}, | ||
"koshien.other_player_y": { | ||
"snippet": "koshien.other_player_y", | ||
"description": "対戦キャラクタの y座標" | ||
}, | ||
"koshien.player_x": { | ||
"snippet": "koshien.player_x", | ||
"description": "プレイヤーの x座標" | ||
}, | ||
"koshien.player_y": { | ||
"snippet": "koshien.player_y", | ||
"description": "プレイヤーの y座標" | ||
}, | ||
"koshien.enemy_x": { | ||
"snippet": "koshien.enemy_x", | ||
"description": "妨害キャラクタの x座標" | ||
}, | ||
"koshien.enemy_y": { | ||
"snippet": "koshien.enemy_y", | ||
"description": "妨害キャラクタの y座標" | ||
}, | ||
"koshien.goal_x": { | ||
"snippet": "koshien.goal_x", | ||
"description": "ゴールの x座標" | ||
}, | ||
"koshien.goal_y": { | ||
"snippet": "koshien.goal_y", | ||
"description": "ゴールの y座標" | ||
}, | ||
"koshien.turn_over": { | ||
"snippet": "koshien.turn_over", | ||
"description": "ターンを終了する" | ||
}, | ||
"koshien.coordinate_of_x": { | ||
"snippet": "koshien.coordinate_of_x(${1:'0:0'})", | ||
"description": "(0:0) のx座標" | ||
}, | ||
"koshien.coordinate_of_y": { | ||
"snippet": "koshien.coordinate_of_y(${1:'0:0'})", | ||
"description": "(0:0) のy座標" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
let formatMessage = messageData => messageData.defaultMessage; | ||
|
||
/** | ||
* Koshien extension | ||
*/ | ||
|
||
import koshienIconURL from './koshien.png'; | ||
import koshienInsetIconURL from './koshien-small.png'; | ||
import translations from './translations.json'; | ||
|
||
const entry = { | ||
get name () { | ||
return formatMessage({ | ||
defaultMessage: 'Smalruby Koshien', | ||
description: "Name for the 'koshien' extension", | ||
id: 'koshien.entry.name' | ||
}); | ||
}, | ||
extensionId: 'koshien', | ||
iconURL: koshienIconURL, | ||
insetIconURL: koshienInsetIconURL, | ||
get description () { | ||
return formatMessage({ | ||
defaultMessage: 'Smalruby Koshien AI.', | ||
description: "Description for the 'koshien' extension", | ||
id: 'koshien.entry.description' | ||
}); | ||
}, | ||
featured: true, | ||
disabled: false, | ||
bluetoothRequired: false, | ||
internetConnectionRequired: false, | ||
launchPeripheralConnectionFlow: false, | ||
useAutoScan: false, | ||
helpLink: 'https://smalruby-koshien.netlab.jp/', | ||
setFormatMessage: formatter => { | ||
formatMessage = formatter; | ||
}, | ||
translationMap: translations | ||
}; | ||
|
||
export {entry}; // loadable-extension needs this line. | ||
export default entry; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"en": { | ||
"koshien.entry.name": "Smalruby Koshien", | ||
"koshien.entry.description": "Smalruby Koshien AI." | ||
}, | ||
"ja": { | ||
"koshien.entry.name": "スモウルビー甲子園", | ||
"koshien.entry.description": "スモウルビー甲子園のAIを作成する。" | ||
}, | ||
"ja-Hira": { | ||
"koshien.entry.name": "スモウルビー こうしえん", | ||
"koshien.entry.description": "スモウルビー こうしえんのエー・アイをさくせいする。" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* Define Ruby code generator for Microbit More Blocks | ||
* @param {RubyGenerator} Generator The RubyGenerator | ||
* @return {RubyGenerator} same as param. | ||
*/ | ||
export default function (Generator) { | ||
Generator.koshien_connectGame = function (block) { | ||
const name = Generator.valueToCode(block, 'NAME', Generator.ORDER_NONE) || Generator.quote_('player1'); | ||
return `koshien.connect_game(name: ${name})\n`; | ||
}; | ||
|
||
Generator.koshien_getMapArea = function (block) { | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
return `koshien.get_map_area(${x}, ${y})\n`; | ||
}; | ||
|
||
Generator.koshien_map = function (block) { | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
return [`koshien.map(${x}, ${y})`]; | ||
}; | ||
|
||
Generator.koshien_moveTo = function (block) { | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
return `koshien.move_to(${x}, ${y})\n`; | ||
}; | ||
|
||
Generator.koshien_calcRoute = function (block) { | ||
const srcX = Generator.valueToCode(block, 'SRC_X', Generator.ORDER_NONE) || 0; | ||
const srcY = Generator.valueToCode(block, 'SRC_Y', Generator.ORDER_NONE) || 0; | ||
const dstX = Generator.valueToCode(block, 'DST_X', Generator.ORDER_NONE) || 0; | ||
const dstY = Generator.valueToCode(block, 'DST_Y', Generator.ORDER_NONE) || 0; | ||
const exceptCells = Generator.quote_( | ||
Generator.getFieldValue(block, 'EXCEPT_CELLS', Generator.ORDER_NONE) || ' ' | ||
); | ||
const result = Generator.quote_( | ||
Generator.getFieldValue(block, 'RESULT', Generator.ORDER_NONE) || ' ' | ||
); | ||
|
||
// eslint-disable-next-line max-len | ||
return `koshien.calc_route(src: [${srcX}, ${srcY}], dst: [${dstX}, ${dstY}], except_cells: ${exceptCells}, result: ${result})\n`; | ||
}; | ||
|
||
Generator.koshien_setItem = function (block) { | ||
const item = Generator.getFieldValue(block, 'ITEM') || null; | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
return `koshien.set_${item}(${x}, ${y})\n`; | ||
}; | ||
|
||
Generator.koshien_loadMap = function (block) { | ||
const location = Generator.valueToCode(block, 'LOCATION', Generator.ORDER_NONE) || Generator.quote_('map1'); | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
return [`koshien.load_map(${location}, ${x}, ${y})`]; | ||
}; | ||
|
||
Generator.koshien_saveMapAll = function (block) { | ||
const location = Generator.valueToCode(block, 'LOCATION', Generator.ORDER_NONE) || Generator.quote_('map1'); | ||
return `koshien.save_map_all(${location})\n`; | ||
}; | ||
|
||
Generator.koshien_locateObjects = function (block) { | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
const sqSize = Generator.valueToCode(block, 'SQ_SIZE', Generator.ORDER_NONE) || 5; | ||
const objects = Generator.valueToCode(block, 'OBJECTS', Generator.ORDER_NONE) || Generator.quote_('A B C D'); | ||
const result = Generator.quote_( | ||
Generator.getFieldValue(block, 'RESULT', Generator.ORDER_NONE) || ' ' | ||
); | ||
|
||
// eslint-disable-next-line max-len | ||
return `koshien.locate_objects(sq_size: ${sqSize}, cent: [${x}, ${y}], objects: ${objects}, result: ${result})\n`; | ||
}; | ||
Generator.koshien_targetCoordinate = function (block) { | ||
const target = Generator.getFieldValue(block, 'TARGET') || 'player'; | ||
const coordinate = Generator.getFieldValue(block, 'COORDINATE') || 'x'; | ||
return [`koshien.${target}_${coordinate}`]; | ||
}; | ||
Generator.koshien_turnOver = function () { | ||
return `koshien.turn_over\n`; | ||
}; | ||
Generator.koshien_coordinateOf = function (block) { | ||
const where = Generator.valueToCode(block, 'WHERE', Generator.ORDER_NONE) || Generator.quote_('0:0'); | ||
const coordinate = Generator.getFieldValue(block, 'COORDINATE') || null; | ||
return [`koshien.coordinate_of_${coordinate}(${where})`]; | ||
}; | ||
|
||
return Generator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.