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 remote-tracking branch 'remotes/speak-mentaiko/kousien' into sp…
…eak-mentaiko-kousien
- Loading branch information
Showing
7 changed files
with
391 additions
and
3 deletions.
There are no files selected for viewing
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,78 @@ | ||
{ | ||
"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.calc_route": { | ||
"snippet": "koshien.calc_route(src:'${1:0:0}',dst:'${2:0:0}' except_cells:${3:1}])", | ||
"description": "2点間の最短距離 始点 x座標 (0) y座標 (0) 終点 x座標 (0) y座標 (0) 通らない道 リスト (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.map": { | ||
"snippet": "koshien.map(${1:0},${2:0} on:${3:'map_1'})", | ||
"description": "x座標 (0) y座標 (0) のマップ情報を('map_1')に保存" | ||
}, | ||
"koshien.map_all": { | ||
"snippet": "koshien.map_all(save_as:${'map_1'})", | ||
"description": "マップ情報を('map_1')に保存" | ||
}, | ||
"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.connect_game": { | ||
"snippet": "koshien.connect_game(player_name:${1:'test'})", | ||
"description": "プレイヤー名('test')ゲームに接続する" | ||
}, | ||
"koshien.position_x": { | ||
"snippet": "koshien.position_x(${1:'0:0'})", | ||
"description": "('0:0')のx座標" | ||
}, | ||
"koshien.position_y": { | ||
"snippet": "koshien.position_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
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,70 @@ | ||
/** | ||
* Define Ruby code generator for Microbit More Blocks | ||
* @param {RubyGenerator} Generator The RubyGenerator | ||
* @return {RubyGenerator} same as param. | ||
*/ | ||
|
||
export default function (Generator) { | ||
Generator.koshien_move_to = 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_calc_route = function (block) { | ||
const src_x = Generator.valueToCode(block, 'SRC_X', Generator.ORDER_NONE) || 0; | ||
const src_y = Generator.valueToCode(block, 'SRC_Y', Generator.ORDER_NONE) || 0; | ||
const dst_x = Generator.valueToCode(block, 'DST_X', Generator.ORDER_NONE) || 0; | ||
const dst_y = Generator.valueToCode(block, 'DST_Y', Generator.ORDER_NONE) || 0; | ||
const list = Generator.valueToCode(block, 'LIST', Generator.ORDER_NONE) || 0; | ||
|
||
return [`koshien.calc_route(src:"${src_x}:${src_y}",dst:"${dst_x}:${dst_y}",except_cells:${list})`]; | ||
Check failure on line 20 in src/lib/ruby-generator/koshien.js
|
||
}; | ||
Generator.koshien_get_map_area = 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_set_item = 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_map = function (block) { | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
const location = Generator.valueToCode(block, 'LOCATION', Generator.ORDER_NONE) || Generator.quote_('map_1'); | ||
return [`koshien.map(${x},${y}, on: ${location})`]; | ||
}; | ||
Generator.koshien_map_all = function (block) { | ||
const location = Generator.valueToCode(block, 'LOCATION', Generator.ORDER_NONE) || Generator.quote_('map_1'); | ||
return [`koshien.map_all(save_as: ${location})`]; | ||
}; | ||
Generator.koshien_locate_objects = function (block) { | ||
const x = Generator.valueToCode(block, 'X', Generator.ORDER_NONE) || 0; | ||
const y = Generator.valueToCode(block, 'Y', Generator.ORDER_NONE) || 0; | ||
const size = Generator.valueToCode(block, 'SIZE', Generator.ORDER_NONE) || 5; | ||
const item = Generator.valueToCode(block, 'ITEM', Generator.ORDER_NONE) || Generator.quote_('["A","B","C","D"]'); | ||
|
||
return [`koshien.locate_objects(sq_size:${size},cent:"${x}:${y}",objects:${item})`]; | ||
}; | ||
Generator.koshien_target_coordinate = function (block) { | ||
const target = Generator.getFieldValue(block, 'TARGET') || null; | ||
const coordinate = Generator.getFieldValue(block, 'COORDINATE') || null; | ||
return [`koshien.${target}_${coordinate}`]; | ||
}; | ||
Generator.koshien_turn_over = function () { | ||
return `koshien.turn_over\n`; | ||
}; | ||
Generator.koshien_connect_game = function (block) { | ||
const name = Generator.valueToCode(block, 'NAME', Generator.ORDER_NONE) || Generator.quote_('test'); | ||
return `koshien.connect_game(player_name:${name})\n`; | ||
}; | ||
Generator.koshien_position_coordinate = function (block) { | ||
const where = Generator.valueToCode(block, 'WHERE', Generator.ORDER_NONE) || Generator.quote_('0:0'); | ||
const coordinate = Generator.getFieldValue(block, 'COORDINATE') || null; | ||
return [`koshien.position_${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.