Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ぼくのかんがえたさいきょうの放置ゲームを作ってる話 / saikyou-houti-game

ぼくのかんがえたさいきょうの放置ゲームを作ってる話 / saikyou-houti-game

kthatoto

June 28, 2021
Tweet

More Decks by kthatoto

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ ͸ͱ ɾTwitterɿ@kthatoto ɾVue, Nuxt, TypeScript, Ruby, Rails, Go ɹFirebase,

    AWS ɾझຯɿLTۦಈ։ൃ, ์ஔήʔϜ ɾΤϯδχΞ6೥໨ ɾࠇ͍ը໘͔ͬ͜Αͯ͘޷͖Ͱ͢ ɾVue Composition API ͕޷͖Ͱ͢ ɹ (ྺ1೥ͪΐ͍)
  2. ์ஔήʔϜ஌ͬͯ·͔͢ʁ ༗໊ͳͷ͸ Cookie Clicker খֶੜ࣌୅ͷ์ஔήʔϜ ҭͯ԰ʹ༬͚ͯΞΠεͷ๮Λચ୕όαϛͰ ڬΜͰ্Ωʔԡͬ͠ͺঢ়ଶͰֶߍ΁ (1าา͘ͱܦݧ஋1΋Β͑ΔγεςϜ) ॳΊͯLv100ʹͨ͠ϙέϞϯ͸ ΩϞϦ

    (ਐԽ͠ͳ͔ͬͨ) 2ສऑ࣌ؒ༡Μͩ ΅͘ΒͷΞΠϥϯυ 2018/12/28͔Βຖ೔ඞͣԿ͔͠Βͷߋ৽͕͋ͬͨήʔϜ 2021/4/30Ͱߋ৽ఀࢭɻ͔ͨ͠2019೥1݄͘Β͍͔Βࢀઓ
  3. ͭ·Γ͜͏͍͏͜ͱ ϢʔβʔPC ϒϥ΢β ݋࢜.rb ૐཿ.js $ ruby ݋࢜.rb ݋࢜ૢ࡞த... $

    node ૐཿ.rb ૐཿૢ࡞த... ήʔϜαʔόʔ ௚઀ૢ࡞ ΞΧ΢ϯτσʔλ ϓϨΠϠʔσʔλ Ϟϯελʔσʔλ Ϛελʔσʔλ ϓϨΠϠʔૢ࡞ ότϧγεςϜ ΞΠςϜ࢖༻ ϞϯελʔAI etc... API API CLI JavaScript
  4. Termworld 0 Α͠࡞Δͧʂ ຀৔෺ޠ΍ϧʔϯϑΝΫτϦʔͷΑ͏ʹ೶ۀܥίϯςϯπཉ͍͠ʂ ·ͣ೶ۀܥίϯςϯπͷΈͷίϚϯυΛ࡞ͬͯΈΑ͏ʂ λʔϛφϧ্Ͱ࡞෺Λҭͯͯग़ՙɺಘͨࢿۚࢿݯ Λผίϯςϯπ(๯ݥ,๵қ,ΞΠςϜ੡࡞ͱ͔ͱ͔) ͷࢿۚࢿݯͱͯ͠ѻ͑ΔΑ͏ʹ͠Α͏ʂ (ήʔϜͷϚΠΫϩαʔϏεԽͩʂ) rubyಘҙͩ͠gemͱͯ͠࡞ͬͯΈΔ

    gem install ͚ͩͨ͠Β༡ͼ͍ͨ ݴޠɾϥΠϒϥϦ Ruby thor (for CLI) sqlite3 (ϑΝΠϧʹσʔλॻ͖ࠐΈ) $ tw-farm show field --id=1 ┏━━━┳━━━┳━━━┓ ┃ b ┃ v ┃ ┃ ┣━━━╋━━━╋━━━┫ ┃ f ┃ v ┃ f ┃ ┗━━━┻━━━┻━━━┛ Πϝʔδ
  5. Termworld Ⅰ CLI: https://github.com/kthatoto/termworld-ruby Server: https://github.com/kthatoto/termworld-server-rails $ termworld login ϝʔϧΞυϨεೖྗ

    $ termworld user create PlayerΛ࡞੒ $ termworld user:<name> wakeup PlayerΛىಈ $ termworld user:<name> terminal ήʔϜλʔϛφϧΠϯλʔϑΣʔεΛىಈ खؒͱίπ͕͍ΔͷͰ Docker͚ͩͰ͸༡΂ͳ͍Ͱ͢
  6. Termworld Ⅱ Α͠࡞Δͧʂʂʂ΍ͬͺΓgem install͡Όͳͯ͘όΠφϦ഑෍͍ͨ͠... CLI͸GoͰ࡞ͬͯ΍Δʂͦͨ͠Β͔ͤͬͩ͘͠αʔόʔ΋GoͰ࡞Γ͍ͨ ͣͬͱͩ͜ΘͬͯͨɺλʔϛφϧViewΛ΍ΊͯWeb Viewʹ͠Α͏ʂ Ϛελʔσʔλͱ͔࡞Βͳ͍ͱͳ ͍͍πʔϧͳ͍͔ͳ... ͳͦ͞͏

    RPGπΫʔϧΈ͍ͨͳ΋ͷࣗ෼Ͱ࡞Δ͔ʂ CLI͔ΒϓϨΠϠʔपลঢ়ଶ(εςʔλε,Ϛοϓ, ଞΩϟϥͷҐஔ,࣋ͪ෺ͳͲ)ΛશͯऔಘͰ͖Δ Α͏ʹ͢Ε͹λʔϛφϧViewΫϥΠΞϯτ͸ ࡞ΕΔ͸ͣʂޙ͔Β࡞ΕΔ͜ͱ͕ॏཁ ࢖༻ݴޠɾϥΠϒϥϦ Go cobra(CLI), viper(config file), gin gorilla/websocket Nuxt, Express MongoDB, Cypress, GitHub Actions $ termworld up Πϝʔδ $ termworld attack
  7. Termworld Ⅱ CLI: https://github.com/kthatoto/termworld Server: https://github.com/kthatoto/termworld-server ϝʔϧΞυϨεೝূػೳ $ termworld login

    ϝʔϧΞυϨεೖྗ ϩϯάϙʔϦϯάͯ͠ೝূ ͞ΕΔͷΛ଴ͭ Token෇͖URL͕ ϝʔϧͰಧ͘ GETϦΫΤετͰೝূ੒ޭΛ αʔόʔʹ௨஌ ϩϯάϙʔϦϯάͷϨεϙϯεͰ ೝূ͞Εͨ͜ͱΛऔಘ Login success! ϓϨΠϠʔ࡞੒/Ұཡ CLI $ termworld player create Player࡞੒ $ termworld player list PlayerҰཡ Player͕ىಈ͞Εͨ͜ͱΛ֬ೝ $ termworld g <name> start PlayerΛ໊લࢦఆͰىಈ ͦͷଞϓϨΠϠʔૢ࡞ (Ҡಈ/ΞΫγϣϯͳͲ) ΋͜ͷίϚϯυͰߦ͏
  8. σʔλϕʔε Termworld Ⅱ ϢʔβʔPC αʔόʔ ௚઀ૢ࡞ ΞΧ΢ϯτσʔλ ϓϨΠϠʔσʔλ Ϟϯελʔσʔλ Ϛελʔσʔλ

    ϓϨΠϠʔૢ࡞ ότϧγεςϜ ΞΠςϜ࢖༻ ϞϯελʔAI etc... WebSocket ΤϯυϙΠϯτ JavaScript ϒϥ΢βGUI API ϫʔΧʔϓϩηε Ϣʔβʔೖྗ $ move up $ login CLI ݋࢜.rb $ ruby ݋࢜.rb HTTP௨৴ WebSocket௨৴ RPC௨৴ γεςϜίʔϧ ϚελʔσʔλϚωʔδϟʔ DBίωΫγϣϯ Ϛοϓσʔλ ΞΠςϜσʔλ Ϟϯελʔσʔλ https://github.com/kthatoto/tw-master-data-manager https://github.com/kthatoto/termworld https://github.com/kthatoto/termworld-server
  9. ์ஔήʔϜͱͯ͠༡Ϳ ʔ ϞϯελʔΛङΓ·͘ΔεΫϦϓτΛॻ͘ ઓಆಛԽύʔςΟʹରͯ͠૸ΒͤΔ ʔ ՙ෺͕͍ͬͺ͍ʹͳͬͨΒ֗ʹ໭ͬͯՙ෺੔ཧ͢ΔεΫϦϓτΛॻ͘ ඇઓಆܥՙ෺࣋ͪಛԽϓϨΠϠʔʹରͯ͠૸ΒͤΔ ʔ ϞϯελʔΛආ͚ͯΞΠςϜऩू͚ͩ͢ΔεΫϦϓτΛॻ͘ ඇઓಆܥΞΠςϜऩूޮ཰ಛԽϓϨΠϠʔʹରͯ͠૸ΒͤΔ

    ʔ ҆શʹ֗ʑΛҠಈͯ͠ަқͯ͠ࢿۚΛՔ͙εΫϦϓτΛॻ͘ ඇઓಆܥճආ&ަқಛԽϓϨΠϠʔʹରͯ͠૸ΒͤΔ ʔ ͻͨ͢ΒࡶڕϞϯελʔΛ౗͠·͘ΓϨΞυϩοϓΛૂ͏εΫϦϓτΛॻ͘ ӡۃ޿ൣғ߈ܸಛԽϓϨΠϠʔʹରͯ͠૸ΒͤΔ ͳͲͳͲɻ͜͏͍͏ϓϨΠ͕Ͱ͖ΔήʔϜγεςϜΛ໨ࢦͯ͠·͢
  10. reactive ͱ͍͏ؔ਺ Ҿ਺ obj: T , ܕҾ਺ T ͕༩͑ΒΕΔ (ͦͯ͜͠ͷ

    T ͸ object ͷαϒλΠϓͰ͋Δ) ͜ͷؔ਺ͷ໭Γ஋ͷܕ͸ UnwrapRef<T> function reactive
  11. UnwrapRef ͱ͍͏ܕ ܕҾ਺ T ͕༩͑ΒΕΔ ͜ͷܕ͸ T ͕ Ref<V> (V͸೚ҙ)

    ͷܗΛ͍ͯͨ͠Β UnwrapRefSimple<V> ͦ͏͡Όͳ͚Ε͹ UnwrapRefSimple<T> ͱ͍͏ܕʹͳΔ (Ref ʹ͍ͭͯ͸লུ) Conditional Types & infererence type UnwrapRef
  12. UnwrapRefSimple ͱ͍͏ܕ ܕҾ਺ T ͕༩͑ΒΕΔ T ͕ Function | CollectionTypes

    | BaseTypes | Ref ͷαϒλΠϓͰ͋Ε͹ ͦͷ·· T ͱ͍͏ܕʹͳΔ ͦ͏͡Όͳ͚Ε͹...(ଓ͘) type UnwrapRefSimple 1/3
  13. T ͕ Array<any> ͷαϒλΠϓͰ͋Ε͹ ͜ͷ഑ྻͷͦΕͧΕͷཁૉͷܕΛ T[K] ͱ͢Δͱ ͦΕͧΕͷཁૉ͕ UnwrapRefSimple<T[K]> ͱ͍͏ܕʹͳΔ

    ͦ͏͡Όͳ͚Ε͹...(ଓ͘) type UnwrapRefSimple 2/3 ྫ) UnwrapRefSimple<[number, Resource]> = [UnwrapRefSimple<number>, UnwrapRefSimple<Resource>]
  14. UnwrappedObject ͱ͍͏ܕ ܕҾ਺ T ͕༩͑ΒΕΔ (T extends object Λຬͨ͢લఏͰ) T

    ͷͦΕͧΕͷ key,value pairͷ͏ͪvalue(T[P])Λ UnwrapRef<T[P]> ʹม׵ͨ͠ܕʹͳΔ type UnwrappedObject ྫ) UnwrappedObject<{ key1: number, key2: Resource }> = { key1: UnwrapRef<number>, key2: UnwrapRef<Resource> } ͋·Γॏཁ͡Όͳׂ͍ʹෳࡶͳͷͰ লུ͠·͢ (& ͷه๏͸ Intersection Typesͱ͍͏ػೳͰ͢)
  15. reactive<{ resources: Array<Resource> }> => UnwrapRef<{ resources: Array<Resource> }> =>

    UnwrapRefSimple<{ resources: Array<Resource> }> => UnwrappedObject<{ resources: Array<Resource> }> => { resources: UnwrapRef<Array<Resource>> } => { resources: UnwrapRefSimple<Array<Resource>> } => { resources: Array<UnwrapRefSimple<Resource>> } ऴྃ UnwrapRefSimple<Resource> ͜͜ͷܭࢉ͕Ͱ͖ͳ͍ ͪΌΜͱܭࢉͯ͠ΈΔ