From 92907d02e214bfedcbc4c64b28eb935f363d8431 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 26 May 2019 12:01:16 -0500 Subject: [PATCH] fun: rock! --- resource/rock.entity.json | 1 + resource/rock.png | Bin 0 -> 441 bytes server/create-fixtures.js | 2 + server/fixtures/rock.entity.js | 123 +++++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 resource/rock.entity.json create mode 100644 resource/rock.png create mode 100644 server/fixtures/rock.entity.js diff --git a/resource/rock.entity.json b/resource/rock.entity.json new file mode 100644 index 0000000..9a20387 --- /dev/null +++ b/resource/rock.entity.json @@ -0,0 +1 @@ +{"traits":{"collider":{"params":{"isSensor":true}},"damaging":{"params":{"damageSpecs":[{"affinity":0,"lock":0.25,"power":50,"variance":0.1}]}},"directional":{"params":{"directionCount":4}},"existent":{"state":{"name":"Rock"}},"item":{"params":{"itemActions":{"type":"actions","traversals":[{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"setDoesNotDamage"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"user"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"user"},{"type":"key","key":"list"},{"type":"key","key":"addEntity"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"item"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"setPosition"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"user"},{"type":"key","key":"position"}]}]}]},{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"direction"}],"value":{"type":"traversal","steps":[{"type":"key","key":"user"},{"type":"key","key":"direction"}]}},{"type":"traversal","steps":[{"type":"key","key":"item"},{"type":"key","key":"moveFor"},{"type":"invoke","args":[{"type":"literal","value":0.5}]}]},{"type":"traversal","steps":[{"type":"key","key":"user"},{"type":"key","key":"list"},{"type":"key","key":"removeEntity"},{"type":"invoke","args":[{"type":"traversal","steps":[{"type":"key","key":"item"}]}]}]}]},"slotImages":{"default":"/rock.png"}}},"layered":{},"listed":{},"mobile":{"state":{"speed":200}},"physical":{},"pictured":{"params":{"images":{"initial":{"offset":[0,0],"size":[12,12],"uri":"/rock.png"}}}},"positioned":{},"roomed":{},"shaped":{"params":{"shape":{"type":"rectangle","position":[0,0],"size":[12,12]}}},"visible":{}}} \ No newline at end of file diff --git a/resource/rock.png b/resource/rock.png new file mode 100644 index 0000000000000000000000000000000000000000..82e7043253d0e76415c53fa205a9f6b71cf04f64 GIT binary patch literal 441 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kwj^(N7l!{JxM1({$v_d#0*}aI z1_o|n5N2eUHAey{$X?><>&pI^Rf^Y$Yn|;?YoL&1iEBiObAE1aYF-J0b5UwyNotBh zd1gt5g1e`0KzJjcI0FNtqNj^vh{pN36Zd)_P7pXY-`ucStZ>EprCf_*yBq$L|OoIEVpb3bS|+g&dF^X}bF z>j(WwoRwZlOYT4Tw6868ZPUw{kqiqCcg?eC^z+Nku;%mmEx9w%&-ZY`>}+kr-<3?U z_wOii*tAS|uwBJi`SU5)ZTOe`*(Uv;&(r!(->lJ*-hnOtY53&ctM-ST8s zc~83gg!vNfPC}by#b3oqdc|`^OTQLys<9MUIm_=ew|9t^*vhc=m)p~SeVbgatGAws hq43<~h5uji&Y7M6_+M1gZD5Epc)I$ztaD0e0ss>@vOWL+ literal 0 HcmV?d00001 diff --git a/server/create-fixtures.js b/server/create-fixtures.js index 2589862..0655124 100644 --- a/server/create-fixtures.js +++ b/server/create-fixtures.js @@ -28,6 +28,8 @@ writeFixture('mama-kitty.entity.json', mamaKittyJSON()); // Write items. import {potionJSON} from './fixtures/potion.entity'; writeFixture('potion.entity.json', potionJSON()); +import {rockJSON} from './fixtures/rock.entity'; +writeFixture('rock.entity.json', rockJSON()); // Write rooms. import {kittyFireJSON} from './fixtures/kitty-fire.room'; writeFixture('kitty-fire.room.json', kittyFireJSON()); diff --git a/server/fixtures/rock.entity.js b/server/fixtures/rock.entity.js new file mode 100644 index 0000000..537ddee --- /dev/null +++ b/server/fixtures/rock.entity.js @@ -0,0 +1,123 @@ +import {buildInvoke, buildTraversal} from '@avocado/behavior'; + +import {AFFINITY_NONE} from '../../common/combat/constants'; + +// Healing potion. +export function rockJSON() { + // Set as not damaging to user. + const setDoesNotDamageUser = buildInvoke( + ['item', 'setDoesNotDamage'], + [ + buildTraversal(['user']), + ], + ); + // Add item to list. + const addToList = buildInvoke( + ['user', 'list', 'addEntity'], + [ + buildTraversal(['item']), + ], + ); + // Set item to user position. + const setToUserPosition = buildInvoke( + ['item', 'setPosition'], + [ + buildTraversal(['user', 'position']), + ], + ); + // Move in direction user is facing for 1 second. + const turn = buildTraversal( + ['item', 'direction'], + buildTraversal(['user', 'direction']), + ); + const move = buildInvoke(['item', 'moveFor'], [ + 0.5, + ]); + // Remove from list. + const removeFromList = buildInvoke( + ['user', 'list', 'removeEntity'], + [ + buildTraversal(['item']), + ], + ); + return { + traits: { + collider: { + params: { + isSensor: true, + }, + }, + damaging: { + params: { + damageSpecs: [ + { + affinity: AFFINITY_NONE, + lock: 0.25, + power: 50, + variance: 0.1, + }, + ], + }, + }, + directional: { + params: { + directionCount: 4, + }, + }, + existent: { + state: { + name: 'Rock', + }, + }, + item: { + params: { + itemActions: { + type: 'actions', + traversals: [ + setDoesNotDamageUser, + addToList, + setToUserPosition, + turn, + move, + removeFromList, + ], + }, + slotImages: { + default: '/rock.png', + }, + }, + }, + layered: {}, + listed: {}, + mobile: { + state: { + speed: 200, + }, + }, + physical: {}, + pictured: { + params: { + images: { + initial: { + offset: [0, 0], + size: [12, 12], // Derive? + uri: '/rock.png', + }, + } + }, + }, + positioned: {}, + roomed: {}, + shaped: { + params: { + shape: { + type: 'rectangle', + position: [0, 0], + size: [12, 12], + }, + }, + }, + visible: {}, + }, + }; +}