forked from scratchfoundation/scratch-gui
-
-
Notifications
You must be signed in to change notification settings - Fork 16
Speak mentaiko kousien #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
600cbba
fix: add extension Kousien
speak-mentaiko 16a3b05
fix: add Ruby code
speak-mentaiko 84d3d65
fix: add ruby to blocks
speak-mentaiko cfa4234
fix: remove some dead code
speak-mentaiko 31b81d7
fix: add completion
speak-mentaiko a1ad67a
fix: change block shape
speak-mentaiko 2676009
fix: correcting completion
speak-mentaiko f36ccf9
fix: add blocks to ruby
speak-mentaiko 522fc73
fix: add all ruby to block
speak-mentaiko f9c541d
fix: correction complement
speak-mentaiko 644636f
Merge remote-tracking branch 'remotes/speak-mentaiko/kousien' into sp…
takaokouji 1fe23b4
style: eslint and add some icon
takaokouji ffdec69
Merge branch 'develop' into speak-mentaiko-kousien
takaokouji 42ae1bf
feat: new extension define
takaokouji 6b94b09
feat: add koshien blocks
takaokouji 2cc3e70
feat: update scratch-vm
takaokouji 18246c4
test: koshien
takaokouji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.