Patricia Sauer - Authentic Programming

Dev Log

January 2024

The logo of Monster Friends Forever
January 28, 2024

I am still working on giving the user a present once a day per monster. Today, I have been adding the library react-native-sound to play a sound when a present has been received. This library is easy to integrate and works pretty well.

Additionally, I wasted a lot of time on an assumed "app starts with black screen" error. It took me a while to figure out that the background on my phone was just black whereas it was white on the simulator. As it was working on the simulator, I have been assuming that it would be the same on my phone. The reason was: My phone was in dark mode whereas my simulator wasn't πŸ˜…


The logo of Math Experts
January 23, 2024

While my daughter and my husband were playing Math Experts in two-player mode, they noticed that multiplication equations were generated seldomly. The reason was that if you set the "Calculate up to" property to e.g. 20, the generated factors could be between 1 and 20. Of course, it's very likely to have a result above 20 when multiplying and allowing factors up to 20. In such a case, a new equation would be generated because the "Calculate up to" constraints could not be met. But: I did not ensure that an equation of the same type would be generated. This resulted in multiplication equations not meeting the constraints often and generating other equations in this case, i.e. addition, subtraction and division equations being genrated more often than multiplication equations.

I needed to change two code parts to solve this issue. For multiplications, I don't allow factors up to "Calculate up to" anymore but instead I calculate the square root and round down, i.e. Math.floor(Math.sqrt(maxNumber)). Additionally, I remember what the chosen equation type was and generate another equation of the same type if the constraints are not met.


The logo of Monster Friends Forever
January 10, 2024

Since I persisted the item state after feeding yesterday, I implemented persisting the monster state after feeding today.

To be honest, I thought this would be a quick one. Unfortunately, it wasn't. There are several reasons for this.

Firstly, I did not know that the spread operator creates a shallow copy instead of a deep copy. When changing a deep copy of an object, the underlying object won't be changed. In contrast, when changing nested objects in a shallow copy, the source object is changed as well. This took me a while to figure out. But, I learned something which is great.

Creating a shallow copy of an object in JavaScript: const copy = { ...sourceObject }

Creating a deep copy of an object in JavaScript: const copy = JSON.parse(JSON.stringify(sourceObject))

Secondly, I forgot to change the monster param of the component after feeding which led to the monster state not changing. This took some time to figure out as well.


The logo of Monster Friends Forever
January 09, 2024

Today, I implemented retrieving the user's items, display the amount of foods, and started implementing the feeding mechanism.

Retrieving the user's items and displaying the amount of foods were straight forward and done within a few minutes.

Implementing the feeding mechanism was not that easy. In short: I needed to figure out how to reduce the used food by one. Just using food.quantity-- was not working because this would modify the state of the component directly which lead to an error (You attempted to set the key "quantity" with the value "999" on an object that is meant to be immutable and has been frozen.). The error meant that I was changing an object which is a parameter of the component, the list of items, which is not allowed. Instead, I needed to use food.quantity - 1. It took me a while to figure that out.

As the items were changing their order with the working implementation, I wanted to sort them. The foods will be sorted by aggregated state improvements in descending order. For that, I copied code from the existing project. I did not understand my old implementation in the first place and made some mistakes here and there until I got it working.


The logo of Monster Friends Forever
January 07, 2024

In the previous session, I implemented authentication. This time, I focused on retrieving the user's actual monsters, replacing the previously mocked ones. While working on this, I noticed a bug in the monster, platform, and background mappings which I fixed directly. In short: the wrong monster, platform and background have been displayed.


The logo of Monster Friends Forever
January 06, 2024

Today, I have been adding Firebase Authentication to Monster Friends Forever. I implemented the logic for signing in and out plus a very ugly login screen. Of course, I will improve it in one of my next sessions.


The logo of Math Experts
January 04, 2024

Today, I have been changing the equation generation algorithm of Math Experts such that the same equation is not generated consecutively. Additionally, I removed the 'lost' modal to avoid demotivating the presumably young players.


The logo of Math Experts
January 02, 2024

Today, I have been changing the equation generation algorithm of Math Experts such that divisions by 1 and multiplications by 1 are not generated when the 'Calculating up to' setting is set to greater than 10. 'Calculating up to' is a setting which defines what the largest result of equations should be. For smaller numbers these equations need to be allowed because e.g. for 'Calculating up to' being set to 3 there isn't a division which gives an integer as a result. For numbers larger than 3, the equation generation would work but we would have a very limited amount of possible equations, e.g. for the value 5 we would only have the following possible divisions which would result in an integer: 2:1, 3:1, 4:1, 2:2, 4:2, 4:4 (if I'm not mistaken).


The logo of Monster Friends Forever
January 01, 2024

Today, I have been working on opening the feed and play menu in Monster Friends Forever. The feed menu contains the user's items and in which way each food will affect the monster's state.








Β© 2018 - 2024 Patricia Sauer