YouTubestream· Aug 2, 2024· 1:46:40
!
Thank you.
I'm sorry.
Thank you.
All right, what's up people? How's it going? I think my microphone should be good. Let me know if the audio or the music is a little bit too soft, too loud, that kind of thing. Yeah, it's been a while since I've actually streamed just by myself.
I've been on a couple of streams before, but I figured I was setting. So the reason I wanted to stream today was because I yesterday I had figured out how to do like multi streaming across different platforms. And so I had set up I had set up, you know, just to have it do different platforms.
I had set up YouTube and Twitch and because previously I'd only streamed on YouTube, I guess, for like the Laravel documentation reading. I had streamed on Twitter for that too. And I had everything working. And then today it just like, it showed that it was connected and live on Twitter, but there was no video, at least in my tests, maybe, maybe there was actually a video and I just ended it for no reason. But yeah, I like YouTube better anyways. And like, I'm on YouTube more.
It is crazy though how much Twitter pushes if you're live, like everyone gets a notification for it. But I don't really care about that. I just want to be live on as many platforms as possible. So I'll figure that out later. But yeah, thanks so much for everyone joining already on YouTube. That's like where the party's at. Yeah, so maybe I'll just
stream on youtube maybe i'll give up my my uh delete my twitch account and you can only find me on youtube so if youtube you're looking for um any kind of sponsors sponsorship i should say i am willing to take i'm willing to forego twitch sponsorship and stream solely on youtube
uh but yeah let's uh let's get into so i the the premise for this um i let me switch this over here um i so hey everyone on youtube and then hey no one on twitch right now uh i plan to do the same when getting to regular streaming just youtube yeah i don't have the so i have like overlays i might not have them like set up right now but i have overlays of on chat so if you're chatting on
twitch i have like the overlays but i'll probably like just switch that so like it's just youtube that has overlaid chat like on here um don't worry josh i'm representing the there we go there we go nick i appreciate it and look at that first time chat see it pops up for for for twitch like underneath my chin um because that's why i had set up previously before i switched primarily to to YouTube. So either I'll turn that off maybe I'll turn it off right now.
Either I'll turn that off completely or maybe just do it for YouTube and Twitch. Yeah, YouTube is where it's at. We're not writing JS over here. Hey on Twitch hey gummy beer. Yeah. I don't know if I'll keep doing like both. I know it's nice to have it on everything just in case.
I'll have to decide what I want to do with actual overlays, stuff like that. But yeah, long story short, I saw a bunch of people. Well, ever since a lot of the Twitch. And let me know if the kickstream went. I don't know if I'm going too far over that way. YouTube, Twitter, and Twitch. I'm not even streaming on LinkedIn. I think LinkedIn is a little bit too professional for me. Aaron Francis streams on LinkedIn.
and uh good for him uh but yeah when um the like the twitch awards like with um a lot of like game development stuff going on and stuff like that i was like okay for the longest time i've wanted to make a like turn-based multiplayer strategy game so think of i think
I had this idea when I was like seven. And I was like, okay, chess is cool. But like, imagine there's been multiple games like this. Chess is cool. But imagine like chess with like abilities and hit points and stuff like that. So I figured what better way to learn a bunch of different weird things within game development than trying to build it in Laravel. And I admit,
I'm the Laravel streamer working at Laravel. So LinkedIn is too professional. Yeah, I don't know. It's a little, maybe it's a little, hey, PHP entertain. Nice to have you here. Hey, Jesse. Yeah, maybe, I don't know. Maybe it's too, I don't, like I'm, it's still weird combining my, because there's a lot of like people who know me personally on LinkedIn. And a lot of them don't know what I do. Like they're like, oh yeah,
you just like work on computers right and so it's always been weird of this kind of combining those two worlds and but maybe i should do it maybe i should do a little bit more um yeah so a turn-based strategy game let me pull up some like notes here so i was like i want to do a turn-based
strategy game think like chess with characters abilities and hit points and I the reason why I want to stream this is one because there's gonna be so much stuff I don't know how to build this isn't gonna be like a one-time stream I don't we might we might like I have about an hour and a half which means we
might be able to like we might be able to like get Laravel installed and it takes a little little quicker than that but I think the point the the reason why I want to build a game is one it's always been on my mind two it's great to use technologies that you actually know to learn new things within those technologies so the stuff that like uh the stuff that I want stuff to learn
is this is going to be like a trigger word for people who are watching on youtube or um any any uh too bad it's not on twitter because i feel like people would love this word but i think i can learn event sourcing from building a game so for those who don't know um
uh for those who don't know there is verbs a Laravel package and I think there's actually a yeah board game example so I don't know anything about event sourcing I know that uh Daniel has been trying to get me to figure it out and uh Josh Hansen is uh is trying to get me to figure it out
as well um but i really just don't know how it works my guess is here's what my thought of that um here's my thoughts of what event sourcing is is you have the ability to figure out where you've been so that you know where you're going that's my thought i wish you could stay and watch this josh you gotta go do household chores
catch up with the bond yeah i don't know if we're gonna get too far into it but it'll be nice to see you uh see you catch up in the bond so i appreciate that um almost 11 50 p.m there wow in india uh second door hat by the way yeah i wear hats all the time um yeah i i stayed up pretty late last night myself so i appreciate you uh hanging in there chandon uh gummy beer in case you want to mingle i would be available for second third stream working on a game as well
and build several games already during king of the gen perfect i'd be i'd be down for that yeah there's there's stuff that like i know the reason why i want to do this in laravel one is obviously like that's most of my community and most of the people who are who are watching probably who are just interested in laravel whether you uh build in laravel or not two when you are familiar with
a software like laravel or just like any software development in general you automatically know how you would think through building a game or building whatever solution that you're trying to solve and that's why i want to stick with laravel i know one thing i've always wanted to try you're also building labor there you go you're building a game in laravel gummy i don't know if i should call you gummy beer or just gummy i'll just call you gummy are you building a game in
in Laravel. I've always been interested in Love2D. This is if like Lua seems really, I've never built in Lua, but Lua seems really interesting. And I would build in Lua if I wasn't building in Laravel. Like again, the reason why I want to build this in Laravel is I know how I would approach this. And so I think I can build it faster, but also there's going to be so much stuff I'll learn and which really excites me.
So I've always been excited about things to learn. So when it comes to like event sourcing or how to think through multiplayer lobbies and stuff like that. So everyone always says, hey, the first game you should build should not be a multiplayer game. Well, too bad. I'm gonna do it anyways. Lewis kind of shit if you know Modern PhD. There you go, see, I'm ready. You can also call me Tom. Hey Tom. Do I follow you on Twitter or do you follow me on Twitter, Gummy?
Like, is that how I might know you? It's always weird combining those two worlds kind of thing. NeoVim, by the way. I know, but I don't use NeoVim, so sorry, Jesse. You would convince me of split keyboards for stream band. You would convince me of stream boards. Stream boards. You would convince me of split keyboards before NeoVim. just because I'm really interested in split keyboards but I also know that that's going to
take a while for me to get used to. So yeah, we're going to learn event sourcing. I already know quite a bit about Laravel Reverb just because I've made one video on it on the Laravel channel and then I have a Laricast course coming out that uses reverb pretty heavily in the sense that that you have kind of like these live listening rooms for podcasts. And so that's what I would build with this game.
And some other stuff I'll probably learn is a lot of like just fun JS, maybe like, what's it called? Like canvas type stuff. And that's not even JS, like HTML canvas stuff. I feel like I would learn a bunch of that because I don't necessarily need it to be really flashy graphics wise. I'm okay with it looking just like a regular,
like a flat 2D board, but this could be like something where I could bump it up. So again, those tuning in first time, I have not even written a single line of code. This is me dreaming, because I've always wanted to make a game. And now I'm like, why wouldn't I just build it in there? I know enough about it where I know how to do this. So turn-based strategy game, it's basically chess with characters, abilities, hit points.
I think I could use Caleb Porzio Sushi to basically set all the characters. Also, one of the reasons why I've always wanted to build a game is I love the... I love the... What's it called? I love the stats aspect of building a game.
So when I was playing a lot of League of Legends, or when I was playing... I played this. This is basically what I'm going to base it off. I don't know if it's even still available to see, but there was this game that I played in middle school called Tactics Arena Online. It looks like there's still some stuff available. but it was basically like this turn-based strategy game with like hit points and like
different characters so i'm i guess i'm just trying to replicate the feel of what it felt like when i was in middle school playing this game there was some randomness aspect to it which i think i would have to introduce and stuff like that but there was a lot of uh like strategy to it as well so it was basically like um it was basically like you know uh uh like a an action
chess game and so that's the the kind of like feeling that i want to try to replicate when i am building this again is one just getting the ability to think through okay like how what makes a game balance what makes a game fun but then also like how do you still have an aspect of strategy without it being too without there being that balance of overpowered and underpowered
like players and strategies and stuff like that. Gonna use...Cobra Kai's got you a play date for her birthday. I've always wanted to play it, use a play date. Play date uses Lua, that's interesting. I'm gonna... I love using AlpineJS. That's actually what in the Laracast course that I made that's gonna be probably releasing soon I would imagine. That's what I used a lot of. We built... It was basically just AlpineJS straight through.
Uh, SVG instead of Canvas. Okay, Geometrics is way easier to see this. That makes sense. Okay, so see there's stuff like that that I'll be able to learn. So, uh, we'll probably use like Sushi to hold like the characters, abilities, hit points, that kind of thing. So that way it can, it's easier accessible and because we don't necessarily need this to be fast, if that makes sense. Like this turn-based strategy game, there's
probably going to be you know a specific time limit for each turn maybe like I don't know 60 seconds or something like that so this doesn't need to be a real time game in that sense like technically we don't even need to use reverb we probably do just for this time limit but like we could do we could start it off and not even have a time limit and just say like you join this room and now it
it is your turn to make your move and tell so it's kind of like this it can be done in real time or it can't be and we can use you know polling for that as well but this is going to be still important because if we wanted it to be any sense of real-time strategy game even if it's turn-based you still need that multiplayer aspect to it or if you want to like have a chat or something like
in there um yeah so i guess i'm just trying to replicate that game that i played a lot of uh tactics arena online uh because that was probably like the first multiplayer game i played other than maybe like battlefield 2 i think back in the day uh do you work for get paid by laravel i do work for laravel now so i am um officially a uh kind of like a support engineer for laravel as well
as kind of half and half so i do like some support engineering stuff mostly helping out with the laravel vapor product which is something that i've used for a long time and still love and then i also do a lot of videos for laravel so on the laravel official channel you'll see some of my videos usually i try to do one or two a week as well as my own personal channel that i do on the side um yeah you need reverb to ping the opponent that their round starts yeah uh yeah that's probably
like a good a good reason to as well you could probably use like the database and like uh like livewire events to do it too but yeah you still like if they're in the same room it's helpful to do it instead of having five second polling and stuff like that um real-time match between two players exactly that is what the the goal is to be able to have this
again every this is probably the wrong way of trying to accomplish building your first game is basically making something that is already incredibly difficult like if you were to say let's build chess as a first game most people would say hey that's probably not a good good idea like build tic-tac-toe first but i've never done anything the easy way so we're going to build
a multiplayer chest with specific hit points, stuff like that. Okay, what else would we need? So we'll probably handle this just in like flat file and then we also obviously need like multiplayer ability so like there should be different accounts. So there's accounts for each game.
Yeah. See, in my head, this doesn't seem like that hard of something to accomplish, you know? So why don't we, I'll go ahead and flip to this view right here. Why don't we start doing it? So, let's see. Open this up.
Okay. Your approach is a good disability exercise. Thank you. Yes, that is the goal. There's so much that I think we can learn from building a game. And anyone who has built a game, like I know Gummy you have, or you're building a game, and there's probably a bunch of different people who have either built a game, whether it's small or big or anything like that. You learn so much stuff of all this stuff and it's gonna be applicable not to games as well. So just like thinking through. So we'll start. I don't even know what I would wanna call it,
but it's gonna be like a chess action game strategy. So we'll just call it something extremely generic and we'll just say strategico. There we go. I'm going to use Laravel Breeze with class API. And mostly that's just so we can get accounts.
So the first thing I usually like to do when I'm building anything new, again, first time game. But I already know in my head of how I think this should start off. And it's because it's very similar to applications in a lot of ways. Yeah, you learn so much by building. It's obvious, but still a bit mind blowing. Yeah, exactly. You learn so much by just doing things over and over.
I've built like a couple real world applications and products that are in the wild right now. But at the same time, the stuff that I've learned the most, and obviously I learned a lot from like building them from start to finish. But even the very simple stuff that I've done for videos videos or for you know demos and stuff like that i've always learned so much too because um
there's different like tasks and stuff that you come across where you're like hey how do i now have in a event room like like how do i have multiple people able to be in an event room but only the people who are registered to that game be it in an event room for example like there's gonna be so much stuff and that can be applied to different applications too so strategico
that's a pretty cool name i i'm not gonna stick with it probably but like i i i honestly think that like making a game is so much more fun than building an application but i i know that it's because it's hard to um so yeah let's go ahead open this in vs code
and i'm gonna pull open the chat over here just so i can like read still while i'm while i'm building uh but the first thing i want to do let's go ahead and open this in a web browser and we'll pull that open here okay so I'm not even gonna like worry about oops I'm not even
gonna worry about like styling yet I just want to have the ability to have basically like set up all the structure for it so like the models of okay you need a game should have like its own game room and stuff like that so like how thinking through the different models oops there
we go okay so we can start building it in the dashboard itself with games you get a whole different gummy says and twitch with games you get a whole different relation with the container and events yeah that's a good point to think and it's really similar again i'll talk about this just because this is what kind of
reinvigorated it but i was building um what we're going to be building in the latest lyricast course that i created um is basically a real-time podcast listening app so in the sense that there's a specific start time for when that podcast starts and then you can join that room and listen to the podcasts together so imagine like live streaming a podcast but it's only like a one-time thing
and there was a lot that i learned from building that that i think can be applicable to building this game in the sense that um you know it's you don't have a game that uh uh usually like within like a multiplayer game there's a start time and an end time like that's it and you have to have this synced on the server and like all this fancy stuff and that's what we're going to like
think through in the game so like i learned a lot just from building that real-time podcast listening app and so i think i can apply it to the game as well so um let's see so we have accounts turn-based strategy game so let's look at um why don't we say
uh let's see like some models so first we need games so a game would probably have like uh it has like two two accounts so like two users within the game it has like a set start time um game probably also have like their own
there's multiple turns per game and each turn has its own uh turn time and the turn is also associated with the user and
yeah turns turn time turn associated with the user and a turn has like an event and that's probably like a terrible word yeah gummy actually mentioned recommendation gummy on twitch says don't use the game keyword while building game limited to two players open the more it's going to be limited to two players so two players per game and maybe that's like a good is a room maybe
good word for that yeah lobby room match i think there's lobbies to find games and so a game would then be maybe like a match that's a that's a good word match so match has two users uh um yeah a mod i actually have a video about how my vs code setup it is the capuchin frappe theme and the icons are capuchin frappe as well i'm probably butchering how you say that um
So match has two users. There's a start time per match. There's multiple turns. There's obviously like a winner per each match. The turns have a turn time. They have a user and event is probably a bad name for this, but my thought is a turn has, my thought is a turn has an action. That's a good word. A turn has an action.
So in the sense that each turn is going to hold what happened in that turn. And so a match has a lot of actions based off of turns. And I don't know if this would be like a good like polymorphic relationship. I'm open to ideas from you, Gummy, because I think you're the most experienced and anyone who has an idea.
But my thought is, should a match have actions or should a match just have turns that have actions? My thought is a match has a bunch of actions. So there are actions related to the match, but they're only related through turns because I probably wouldn't need to say, okay, this match has all these actions. Make the action events on the aggregate. Okay, that probably makes sense.
Yeah, so the turns have a bunch of actions and a match has a bunch of actions that are related through turns. And then, so a match has a winner, start time, two users, turns. Each turn has its own turn time. It's associated with the user. It has an action. In this case, the action is what happened during the turn.
a match has characters I don't know if that's the right word for it but it has yeah characters models your match is your gummy says your match is your aggregate and each turn is an event on that aggregate modifying the match state
Matches your aggregate and each turn is an event on the aggregate. Okay, yeah, yeah, yeah. So there's turns, matches the aggregate, and each turn is also an event on aggregate. Don't think in eloquent models when doing event sourcing. See, that's the stuff I probably need to learn.
so like in verbs i i'm guessing this is what i'm going to learn a lot through this there's events and okay instead of knowing just the current state of your app every change event that leads to the the current state is stored.
Okay, yeah, so that's why I'm missing how it's thinking because I'm not necessarily storing all of these turns in their own database model. That's why event sourcing happens. So a match would be a, a match would probably be an eloquent model in the sense that we need a match to start all of this. but the turns would be the event sourcing piece
where every action has a turn, that kind of thing. Okay, I think I get it. Are you going to use Livewire? Yes, I am. So Livewire Alpine, that is the goal. So I'm gonna use Livewire for a lot of the live actions, events and stuff like that within Laravel Reverb. And then we'll do a lot of, hopefully the ability is for me to understand
C combating jargon. Okay, aggregates, there we go. State and verbs, there we go. Okay, now I'm on the same page as you got me. I have not read any of this verbs documentation. I've never heard about event sourcing or learned about event sourcing until now. So we're gonna do it live. So aggregates, so in this case, The state would be our match.
State in verbs would be our match. And then, okay, aggregates are states. You have a projector. Many events sources says you'll have dedicated projectors that listen for events and project data in a convenient shape for your views. They're sometimes called projections or maybe view models. So then you have reactors. Okay. I think I get it.
So states and verbs are simple PHP objects containing data. Stairs. So the entire grouping of stairs is the state. In this case, our match is the state or the aggregate. And the database models reflect where we are now that we've traversed the stairs. Yeah, so the match is the state within verbs or aggregate.
And then the events, I'm assuming source of your data changes. So yeah, the events kind of fit into the state. So the events would be our actions. Yeah, events on aggregate. Events on state in verbs. There we go. It's making more sense in my head. We're creating a new match.
that's its own separate state related to each two users within our models and a match has a start time as a winner there's turns which are events in verbs we can have a turn time and so each turn has its own turn duration so probably
like a max of 60 seconds. Each turn has its own user associated to the turn and an action. And so actions are related through turns to the match. So a match has multiple events of actions through turns.
Mm-hmm. Okay. I think it is making more and more sense. See if I missed anything here. Did you miss anything important? No, not yet. Again, this is me just brainstorming with you, the viewer, along with me of like, how would this work? Because in my head, it's going to be really difficult, but it's also going to be really fun.
um yep capuchin theme frappe and yeah yeah uh great idea to be chess oriented yeah um okay so what's the first thing that we can do the first thing that we can do is let me set up i'm probably not gonna get to figure out what uh
what verbs is but let me like install this so that way like we're ready to go we're gonna install verbs we're gonna publish we're just gonna I always like to get things set up so that when I actually do need it I know that okay things are like in a good spot so we're gonna publish the migrations migrates that we have verb events snapshots state events table and now we can
generate a new event and so the event would be our actions right because our state yeah utilizing state states and verbs or PHP objects so it's creating a new state customer state yes state would be a match okay that's making sense let's do reverb as well because I know I'm just gonna use it so again I always
like to just install things that i'm going to be using um just so i can have things like out the gate so the first thing i want to do is um create new rooms for users so two users can join a room in this case the match and maybe we'll create the this is probably uh probably the wrong way to start
breaking it down. The first thing I want to do is make the ability to have a countdown timer for a match. So a match has... maybe we'll do like turns. And I'll think of this in models first and then maybe I can push it to like event sourcing and stuff like that later. But I think a good starting point would be no more than two people can join a match. Once two people have joined
a match again this is super basic level once two people have joined a match let me write it down oops so what's the first start first start let's create the ability to have uh matches so once two people have joined a match the turn timer starts and i only want turn timers so So basically just one turn timer just to start off with.
So, 60 seconds, there we go. So that'd be a good start to say there are now matches and now we can have that place to store all of these events. So, let's go ahead and Start the reverb server. Nope.
It's because it's already started. It's probably because My Laravel herd setup. Let's see here. Yeah. I can just do this instead. ENV.
There we go. All right, so we have strategico.test. Here's the ability to be able to join a room. We need to see how many people are in that room so that you can only join a room, a match.
So a room starts a match. We'll keep them together. So a room has a match. Let's show all the matches available here and how many people are in that match. So just to start it off, why don't we say PHP Artisan make model and we'll just call this a match. And create a migration for it in a factory.
Name match is reserved. Wow, I did not know that. It makes sense. So... A room it is. What's another word for match? Let's see. Anyone have any ideas here? You also need one shared timer for all players. It's a good idea. You might want to manage the match time on the back end. Lazy Dolly. Thank you so much for joining. Cool hat by the way. Yeah, do you like my indoors hipster hat?
You might want to manage the match time on the back end to prevent front end to prevent front end refresh and reset timer okay yeah one shared timer for all players that makes sense yeah so like a turnaround timer so not only does each turn and so maybe that's like a good way of saying it like a turn has a timer but that's technically associated with the match the match
timer just resets on every turn So maybe that's a good start. So we have a 60 second timer and can pass turns. Like that's a good, I think first step that maybe in the next hour, I think we might be able to get there depending on my ability to code live. Sometimes that's really good. Sometimes it's not that good. So if we have rooms and maybe we'll call this a room now
instead of a match, room, a bunch of different rooms. Once two people have joined the first timer starts So randomly randomly selected one player randomly selected Always 60 seconds on the back end and they can pass turns
I like it PHP artisan make model. We'll call it a room Okay Let's create our rooms table and again This is probably the backwards way to do it if you're doing event sourcing But I'll do it this way first and then and I'll then I'll figure out event sourcing later famous last words so a room their room
it has an id that's pretty much all we i mean we're gonna add a bunch of stuff later to this because and maybe maybe the uh oh this seems neat thanks will nice nice to see you um timer might wait
until two players are there yeah okay that makes sense yeah one's two players the game i know game is probably a bad word for it so like what's another word for game um contest meet event event that's a terrible word because if i'm like doing events or saying that this is this is tough for names. I feel like
that's probably the toughest part because like a room holds people but do I want the room actually being like the match? Like a game match? And maybe like that's a I'll take advice on specific wording. I can tell you that switching from model to event source is pretty tough as you haven't planned your app as event source. Okay.
that's the sentence that makes daniel and john all the dollars um yeah there we go i'll just we'll just like teach them battle that nick says battle that's a challenge battle challenge that's probably just call it game uh i feel like i'm gonna be rewriting so much of this if i uh matches i i learned that matches a a php uh reserved words
I can't necessarily call it. Room being a lobby is just the state of the room. It's a good idea too. Battle. Game match. Fight. The app I'm using for taking notes is Reflect. Reflect.app, I believe. You have the pre, running, and post state, but all in the same room. That's probably true.
that does that does make sense so it's still a room once a room has two players the match has started the room is commenced the room is in action state turn timer starts I guess it could just be a room
so we have an id and yeah let's just let's just do that for now we'll just get a bunch of rooms on the on the page so we'll just say uh we'll create a new live wire volt class we'll say that this is like the the
room lobby again we can refactor a lot of this here I just want to get all the the rooms in one place so if we have the room will also just say state this is this is where event sourcing comes in I know it I know this is where event
sourcing comes in and I'm just gonna have to figure out how this works. Okay, why don't we do that instead? We probably won't get right where I want to be, but we'll learn about vent sourcing together. Okay, so So our state is our room which accumulates and holds every step because and maybe it's not bad. Maybe it's not bad to have
the room have like two states because we need to know is the has the match started or has it finished and maybe that can just be a boolean in the room of two players join the match has started once the game's finished like is game finished um
generating a state so example states let's see loading a state card state load using states in route states implement okay Okay.
Let's use the board game example. So you have a game state. Who's the current active player? Okay, and then you have a player state. For monopoly. So game.
when game started and now we can set game start okay so this makes sense of why room is probably going to be a state in the sense that a room is a game room state game state
and maybe that's like the way of saying it so it's not necessarily a room it's just a game state and maybe a room has a game state that might be a good way of doing it too like a room has a game state hello sorry for calling me okay I don't know how to where my
there we go I don't know why it doesn't let me moderate this I don't know how to do moderation in Twitch chat two states probably will not work turn games probably have more than just game start and game end Okay, yeah, that makes sense.
It makes sense then of why I would need this to be event sourced and why I'm just going to have to bite the bullet and figure out what event sourcing is. Your bank account is a state and each transaction is an event, but you don't start a new bank account only because you switch your address or your employer. That makes sense. I also don't know how to do that as well.
I'm sorry. I'll probably have to figure that out. Let's see. Chat settings. I don't know why it doesn't... Users in chat? How it does? Oh well. I still need to learn all the stuff for everything.
everything uh each room battle could start and end in one unique state lazy dolly says um big boy pants go on and go event sourcing i probably just need to do it players gets experience or stats yep yep so each player is going to have their own unique state within the game
enable show mod icons there we go thank you I appreciate it okay let's just do this then so if we create a new state php artisan verbs
game state and the game state does is game state tied to a room or tied to a model or is it just completely separate like it is event sourcing tied to models
or is it just all in memory ability for your events to be replayed yeah that's I can see how event sourcing especially for games is incredibly pop like is necessary because we have our state and will generate in a fresh app states
directory Okay.
So if we had all of this state, so game state, so like imagine just everything that this has here. and are these things
use thunk verb okay so like is this stuff models like in the monopoly example
i would imagine these would just be models then like like um a game state has a room and a board all that what did I miss? I don't think you need a queue maybe even sources use this player press start button fire event with matchmaking with opponent player rambling
no model directly in the state state I don't use models at all that's what's confusing me I've never like I get that this would be incredibly difficult to build out within models but in my mind I'm
thinking okay like how do I list or how do I show all of the the available rooms within like how do I loop through them player user id in the state uh the results so yeah i would i would have i'll probably have a list of rooms
but each room has its own game state so similar to how like each user is in the the um as soon as i'm used to it i want something else that makes sense yeah i'm gonna start with the the basic room lobby where i'm just using models and i won't
even worry about state here so i'm not gonna try to do that i'm just going to say that um we'll list out the room and then just have players be able to to join so we'll say again this is probably the bad way of doing it but we'll say that a room has a room limit
so first we'll just get in our room factor we'll just we'll just create a bunch of them so we'll say that this the the room
has hmm
I'm going to put it in the middle of the bag.
I'll just have a name for it right now that way I can just generate some in the cedars so I just want to have a bunch of rooms created just to list them
oops
so in the creep in the room lobby i just want to for now just get them listed
so
and then we do need to put this in the dashboard
okay so the idea is each room can have its own two players and if I was to take a look at the event sourcing piece again
and maybe that's what it meant by then the um where was it
in events or in states using states and routes because this is what you would want to do you would need to pass okay yeah you need to pass the state into the route to get the state for the game and so that's probably what we need to do in the dashboard is get all the game states
yes i guess rooms with a toddler refusing to sleep uh what did i miss models are easy with laravel but i don't know how to yeah i i'm guessing by the end of this i'm going to be like i'm going to be a full-blown event sourcing shill but we'll see you have to
get used to event source but as soon as you do you don't want something else um uh i don't think i actually have discord installed on this laptop right now um yeah i'll take you up on that next stream for sure let's do that uh maybe i can read a little bit more just to make sure i understand it uh i think you need a cube maybe event source uses this hello aziz nice to see you
and I think that's it it's starting to make more sense of why event sourcing needs to happen within a game because you would need the game state and as a
a game state i'm that's where i think i'm confused of like for this state how do i have multiple game states i know that let's see if there's a a list of state cash because i know that each each game state would have its own kind of like what we what we see
here in this board game each game state has its own um set of players player ids so how do i make sure game state is unique in that sense though that's where i'm a little bit confused about like so does do i still have to have rooms and each room has its own game
state and how do I kind of connect the two state is part of your events and models are mostly for your application you I should always possible delete all the models that are created and updated via events and rebuild them all by replaying your events our event lifecycle is built emphasize this before we even fire an event we can check you're authorized
to do so. Okay, so this makes me think that the room model is still important because we need unique rooms that hold a game state. So maybe I can keep doing this within the room model, and then I can put the game state in the room. Let's just do this.
That way I can set that up for the create rooms table. I don't know if I want a string of name instead maybe I just want like
because a broom will hold the game state and then how do we get those pieces put together room would hold
let's just for now have a boolean of not as private but like like has started or not that way we can check how many players are in a room first before
because the game state is going to hold all of that information but a room and I get I know this is probably going to be put in the game state eventually migrate fresh just to do that
because we have a has started default false i i just want to switch has started to true when two users are in that room and then the game state can hold all of that
and so we probably need an event maybe this is like an interesting part within because like there's the events within verbs within event sourcing but then there's also like events within reverb which like if we're broadcasting we have these specific events that
we need to create in this case i just want to say like we probably just need a presence channel
So I basically just need to say when two users are in the room, we're just going to switch
it to has started data returned by the authorization callback or maybe the president channel event listeners and yeah yeah maybe not even a presence channel because we can when a user clicks into a room we could even like
fire off the event like there's there's someone else here hmm like joined room
And in our room factory, just so we have...
Nope.
okay so each room probably has its own does livewire work uh but the room only has a projection of the game start state but the room only as projection of the game state.
Let me just start with events, then states, and only after states, the models. Okay, interesting. I'm doing it backwards in a lot of ways, it seems like. Does Livewire work with stateful? How do we deal with state here? I'm used to with Laravel API and Vue.js for my state. Anyone guide me? Yeah, Livewire stateful by default. You're sending the state back and forth via Ajax calls is basically what Livewire does. I doubt we want every event to be stored.
in the db what about the db calls versus performance it's round base so nothing to worry about it's not real time to give it hundreds of events per second only one every few seconds yeah that's that's that's the key part so that that's helpful in this specific instance is we don't necessarily have to worry about you know player location everything like that yeah i think everything's going to be saved in state using event sourcing and we're going to
be using reverb to kind of uh have the timers timers is going to be the biggest thing to and kind of like player actions and everything like that um we can use session for this probably that'd be a good idea you could put an id on the game state okay so the game so i don't necessarily need a room then i could probably have
a game state and can kind of loop through a bunch of different game states that are available so someone was like hey i want to create a game they create their own game state which has its own id uh daniel colburn yeah that's who i really need i know um i know josh also mentioned showing me all about event sourcing as well. Hopefully you get some good sleep you don't want to miss.
I don't think there's gonna be too much to miss. I only have probably like, I only have maybe like 10 or 15 more minutes before I have to call it for today. But I think I got, I am good on like the next steps of one what I need to learn about event sourcing, but then two of what is gonna have to take place with this yeah I know I probably need to do this I do not do
faker extension as much as I should I don't have it yeah I do need to get Daniel on tell me just show me how to do this show me what I'm missing but I because I think that's the biggest thing that I'm thinking through right now because I know that a game state is going to have to be in a state but how
will I like how do you create new like how do you have a user create a new state like cuz I'm thinking in the form of models and so I think think through me here on this because I'm thinking in the form of models in the sense that I have whenever I'm creating something I have a new model that I generated and a user can now create a new instance of that model because they're creating a new record in the
database. In my mind that room would then hold its own game state but if I'm reading everything oops if I am reading everything here correctly then this looks like I probably
need to have like not models at all let's take a look at this one again Everything is purely in event state. In a real world application you would need to implement a way for users to interact with this state. Either through digital HP web or something like that. Ok, yeah, no controllers or labware components. Everything is purely in event state.
The current status of the game with information like who is the current active player, what's the current... Yeah, ok I get that. Let's take a look.
Let's see, do they have like, here. This is what I'm going to need then. I am going to take those examples, going to grab monopoly. Let's see if I can set this up.
Oops. So we have monopoly views. They're signing in. Okay. Components.
okay so yeah there is no models you have
the game ID. So how does that get set? Yeah, so there's no models. It's just all of the game. Okay. Very interesting. Is this just a zone? Yeah, these are just its own classes. Okay.
game controller where it shows the index it's not even like passing any and then we can start events redirecting to the games after login
I think this is just all the actual state of the game because then in states you have game states okay yeah these are just all classes like the bank board and phase those aren't models okay it's just all there's no models very interesting
i don't know if i'm smart enough to understand all this um so then in routes so then we have games we're passing in the game index i i this is where i'm getting lost at like how you can
have multiple games because in the games index game id
It's the monopoly layout. Like where is it getting passed into? Maybe someone, someone knows. A user isn't a child of games, so a user can be eloquent only. Okay. So the user is probably the only model that I'll have. We feel quite dumb when we don't understand.
Exactly. That's why I love live streaming this. I love showing one that it takes me a while to understand something. So when you watch a video of me talking about something, usually I have spent double that time first making sure I understand it properly. and this is going to be turned into a great video in the long run of like what the frick event
sourcing is uh i'll get daniel cole warren on daniel if you're watching i need you um you can mix models with event sourcing so users can be models it sounds like users is probably game over no models um it sounds like users is probably the only piece that i need as
model then I don't need a room because those are just going to be like in in this monopoly example is just going to be this is going to be game states so there's new games and I can trash all of my all of my notes then in the sense
that these can be like game state match state i like match better than game so match state and turns are still gonna be events so like and if I'm following what the monopoly setup is for
states, the player state would be then the turn and so maybe it would be except this player state is more of like the hmm because this is for monopoly like how much money you have but that might be something to think about because in a player state
instead of turns it might be like a like a player state has turns so match state has turns and then I would have a separate state that's what it is of a player state where it has uh you know what the because these these turns and player state are probably going to talk to each other in the sense that a player state has its own characters
or um maybe we'll just say champions that's a bad word for it all right like uh characters what's a good word for that like models um pieces yeah we'll just say so player state has like what is the state of the pieces and there probably is also like a pieces state too of like what is there
like hit points that kind of stuff but i would imagine that could just live in the player state because then you know how many pieces they have what are the hit points for each piece So, peace is separate state.
Player state has action state or match state also has how many turns have passed. I guess that would be like the event history. And then player state would also have, as well as pieces that might even be their separate state of... I don't know about player state then. It would just be pieces.
And maybe that's its own state. So like player state has its own pieces that have their own state. So that part I'm still thinking through. game states which has its own players ids. I'm still missing that piece because we have the controllers game controller we have the index but it's not passing any games into
it. Where is this game id coming from? And how is it being passed? I know this is a work in progress so maybe like it doesn't exist yet um events set up game started okay yeah so
here's where the game id is and maybe so that just like it has its own event that applies to state that's really interesting am i gonna love event sourcing i think that's the that is the the question of the day. Why would you... Here's like a legitimate question for those. Like with Among Us,
you have to know the six-digit game. Oh, okay, okay. They have to probably manually answer. That makes more sense. But there probably is some way to query for all the game states, I would imagine. You could say, hey, give me all the game states that have not yet started and show them in some way shape or form um how come you're not how come you start with monopoly not something similar to i'm not even starting with
monopoly i'm doing it more advanced than this um but the the premise is is like i love learning by figuring out hard things and so we're going to figure out hard things together and so i'm building a chess basically like an action chess game so turn-based strategy um with event sourcing i've Never learned event sourcing before. So this is gonna take a little while. This is only hour one, hour and 15, hour and 10 minute one.
The first hour and 10 minutes and we have some notes. But that's a good thing. Cause I think I've learned that there is no, there is no models in event sourcing. You'd still have models to anything you want to display the UI but they are built around what you want to read not what you have to write as far as I know if that makes sense that makes that makes sense so
you're not in this sense the only thing we would probably need in the UI if I can show and list the game states in the lobby let's say there's a there's an entire lobby and you can click on open and available games so let me put this
in words right here so how to start a game so users can log in or create an
account in the dashboard they can view a list of available and open games or they can start a new one once two people have joined a room the game begins so like I
I imagine a grid of different lobbies in this case. So like there's one big lobby of multiple different waiting or games to be started. And so in that whole scenario, there is probably no models. If I can show a list of game states, which I imagine I should be able to do that.
If I can join a game state by an ID, I could probably view all game states by ID would be my guess. And then once the game begins, it becomes unavailable in the main lobby. But there could be models, for example, outside of the users, because I would imagine a user could be a model
because I would need to display information about their profile, that kind of stuff outside of games. And maybe even things like experience level, that kind of stuff.
So a user might have things like experience level, their profile, maybe like stats on games. All that stuff would technically still be stored in the model. Or probably best to be stored in the model because it's not necessarily part of the game state or player state which exists within a game or a match.
but there could be like a chat room for example in the main lobby and that would be its own model like you wouldn't want that in state um only from yeah event source models are read only okay
event source moment so i could have a list of game states though like if i had a list of match states in this sense views is in the navigation
so views games index join an existing game start a new game
okay so they are asking for the game ID but then yeah I don't know why I'm I'm being kind of dumb in that sense because if if they're asking for a game ID in order to start a game in this sense the components oops
monopoly source uh we'll do the controllers uh source controllers game controller when you're starting a game to show the game you're grabbing the game state and in this case we could probably there's probably a way to load game state for all games or at least have a list of all games so i that is the one piece I have a question for
and I'll ask Daniel or whoever what's the best way to show a list of all games on one screen all game states based off of I just want all game states that the game has not started and since that is loaded in the state like is there a way to query events in that sense or event states let's see Is there a way to query states?
Loading a state State is loaded once then kept in memory even as you apply events and maybe that's what you can't necessarily load a bunch of different states
State collections. Find it helpful real-time to pair your states to your models. States are there to manage event data and memory, which frees up your models to better serve your fundraising guidance. Once, okay. Okay. There we go. This makes sense.
So once you convert you to unique IDs, you can use your state instances ID to correspond directly to a model instance Probably need another state Okay, so I think I think I have the answer a room has a match state and this
state ID This match state would be linked to the room ID so that's how I loop through a bunch of like rooms Now I don't know how I can query give me all the rooms with these states of Like not started because it sounds like
here's my next steps it sounds like rooms are models but linked to match states which we can do here so the question would be how to query models
based off of state or should state control the model by like modifying the has game started column does that make sense my question is does stuff like this just exist in state which I'm guessing not because then there's no way
of like showing has it ended as it started that kind of thing i should probably have this in the model but have the state control the model because this this is what i need to show and if i'm basing off of what this i use my ui or models to serve your front-facing ui needs i need the rooms to show based off of if they've started or not or available whatever wording i want to say so that's that's the biggest question.
And the next question would be the user has all their stats, so that should be good. Do I need, and the room probably has the reverb ID event. Okay, I think those are the biggest next steps. Like rooms are miles blank to match state. I'm probably gonna have to start wrapping it up.
I'm sure to stream today, but I liked jumping back into it. It's been a while since I've streamed, and now I got like solid next steps. So again, this was just kind of like planning phase. We didn't get that far. That's okay. I've left you a Twitter DM. Okay, I appreciate it. A match state has a room. Okay, the room can be deleted and re-projected from the match state.
match state okay so I don't need the model that's gonna be my that's gonna be my homework before next stream I might be able to stream tomorrow to learn a little bit cool concept I planned on making a few games for there myself verb's like no back yeah that's anytime I'm making something it's to learn something new there's very rarely times I make something oh like I've never learned how to do this or I know exactly how to do all this I don't know how to build a game at all I've
never built one and i've never used event sourcing so this is the this is the way i'm going to do it um let's see let's see let's see let's see are you using some kind of filter in obs looks pretty cool your camera lens thank you yeah i am um it's very uh i'll have to make like a quick little video
of how i do it um yeah every like all of the different like ways or like scenes are in obs so like stuff like this is all obs um and i have i believe i have a a uh what's it called let me pull
it up i have on my camera i have like a mask to mask it to like the rounded corners but then i also have a little bit of color correction so i'm using a panasonic lumix g7 as my webcam and then i have a lut that is a free lut for the panasonic g7 and that's like set to maybe like
60 so that gives like a little bit more of like that cinematic type look um but the good thing is i love having it all set up out of the box so i don't do any kind of like color grading or editing when i'm making videos i just record and then i add some music or whatever afterwards um after game's finished add column finish game okay yeah so that's that's the part that i'm
gonna get some help in of like, cause I know that I could probably like redo all of this once I get it done, but I wanna make sure I'm understanding it properly. And that's the thing is like, it's good to just kind of like build and then reiterate when you learn more. But with this, I do like, it is a different mental model. And so I do wanna make sure I understand, okay, what stuff am I storing in the model in the database? And what stuff is just event state?
especially when it comes to games. And this Monopoly one is gonna be one I take a closer look at. I'll go ahead and I'll throw this in the chat for people who are watching. Because I think that's one that I'm going to do a little bit more digging off stream at just to make sure I understand it completely. And maybe I'll try to get this set up as well.
But where does state actually live when there is multiple games? And it's basically trying to get it out of my head too, the sense of there can be multiple games that these users, let's say there's 100 users on the app, there's 10 games that are ready to go who have one user each in them.
once a second user joins that game the game starts but we need the event history also of okay how many how many games is this person one and that's going to be in like the user stat so that's technically probably being saved to the model so stats on games maybe they have like maybe the experience level was like an elo kind of stuff all of this is probably saved to the
model I understand that the room slash a match piece is where I'm confused of which stuff am I going to say to the model which stuff I'm going to keep in the match state yeah I think that will be where I call it for today Josh love you I don't could you make videos on filament I'm recently getting PHP honestly never leaving so would love to see such videos thank you I appreciate that yeah
I am planning on doing like a more of like how to use filaments like forms and actions and stuff within like a live wire app. So that's kind of like one of the next videos that I have kind of in the pipeline. One thing also to note is if you go to cir.re slash suggest that is where you will see a little bit more information on kind of like what people are voting on as the next video I
should make this is obviously a pretty popular one but the which kind of like these two linked together i'm probably going to make one video with both of these but the building assassin filament 3 is something i'm contemplating or going to start planning as well but yeah hopefully i'll see most of you all tomorrow i probably should be able to stream a little bit and maybe we'll see
see how far I get off stream of just kind of like learning and trying to understand all this uh yeah we'll do some some fun stuff once I get it all but yeah I think this was a this was a good stream overall I think I learned a lot I thank I thank you all for for for joining and for for being here with me learning event sourcing I appreciate it um but yeah hopefully you have a good rest of your day. I'll see some of you tomorrow, hopefully.
Until then, have a good one.