New 2moons Version based on 1.8 rewrite with Angular 6

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • New 2moons Version based on 1.8 rewrite with Angular 6

      Hi , in 2016 i rewrite 2moons 1.7.3 using Angular JS , the results are incredible in speed , i made client in angular and server in php just with litle json changes , this split allow to make phone/table apps using cordova for any devices , desktop devices using NwJS or AppJs for all platforms using assets directly , and also can be instaled directly into browser .
      Still i was not satisfied with some results, and i wanted to write in typecript because its modern language and easy to develop so i started now using Angular 6 .
      The results are incredible 90% faster then before .
      2moons is dying slowly , lets make it modern , bether code, stable and optimized , faster then before , anyone interesed into this i would like to work as a team .
      I want to improve it so people can change the game strategy , if they want to switch to medieval from space strategy , or to choose the map type , resources name , bether Vars Editor directly into admin panel , i also work on a star map , a galaxy that contain all solar sistems , diferent zoom levels , high quality images generated in photoshop , sun moon planets , stars , space dust, asteroids , etc , the map is something like Astro Empire , fleets can be seen moving on it , an radar will detect them , people can see other players atacked , i use LeafJS right now , and for medieval gameplay i use resources and textures from Cossack European Wars ( map textures , units, buildings etc. ) .
    • I wrote 2Moons as a fully Angular 13 Client, why would you use Angular 6 or Angular JS which is old? Beside that, i am really excited to see a second, FREE Version to compare it to mine - so i can at least see how bad/good i coded it. Looking forward for the release :thumbsup:

      With a working function like this, literally 95% of the angular service code for your 2Moons Server is done - writing it like this will make it also Multi-Universe ready.

      JavaScript Source Code

      1. doCheckQueues() {
      2. return this.authService.token.pipe(
      3. take(1),
      4. switchMap(token => this.http.get<any>(`https://${token[1]}.myGameUrl.com/game.php?page=buildings&mode=checkQueue&token=${token[0]}`,
      5. { headers : {
      6. 'content-type' : 'application/x-www-form-urlencoded; charset=UTF-8'
      7. }})),
      8. map(buildingData => {
      9. this.getAllQueues().subscribe();
      10. return buildingData;
      11. })
      12. );
      13. }
      Display All
      So, you can call your data and return with JSON like this - so the rest you gotta do is engineering a Authentication System and a Frontend View and which is interactive (similar to what you would do in Javascript) - like said: It took me 6 weeks to do and literally every information is on Page 1 of Google if you are interested.

      The post was edited 1 time, last by Cooperium ().

    • Cooperium wrote:

      I wrote 2Moons as a fully Angular 13 Client, why would you use Angular 6 or Angular JS which is old? Beside that, i am really excited to see a second, FREE Version to compare it to mine - so i can at least see how bad/good i coded it. Looking forward for the release :thumbsup:

      With a working function like this, literally 95% of the angular service code for your 2Moons Server is done - writing it like this will make it also Multi-Universe ready.

      JavaScript Source Code

      1. doCheckQueues() {
      2. return this.authService.token.pipe(
      3. take(1),
      4. switchMap(token => this.http.get<any>(`https://${token[1]}.myGameUrl.com/game.php?page=buildings&mode=checkQueue&token=${token[0]}`,
      5. { headers : {
      6. 'content-type' : 'application/x-www-form-urlencoded; charset=UTF-8'
      7. }})),
      8. map(buildingData => {
      9. this.getAllQueues().subscribe();
      10. return buildingData;
      11. })
      12. );
      13. }
      Display All
      So, you can call your data and return with JSON like this - so the rest you gotta do is engineering a Authentication System and a Frontend View and which is interactive (similar to what you would do in Javascript) - like said: It took me 6 weeks to do and literally every information is on Page 1 of Google if you are interested.

      JavaScript Source Code

      1. getQueueList(queue = null): void {
      2. if (queue === null) {
      3. this.pageService.getData({type: 'game', page: 'buildings', mode: 'queue'} ).subscribe(response => {
      4. this.queue$.next(response.data);
      5. });
      6. }else {
      7. this.queue$.next(queue);
      8. }
      9. }
      :thumbsup:
    • Is that really the right way to update observables?

      Or do you put up simple empty variable and a subscription in the page.ts and a BehaviorObject in service.ts - so you update observables in services and not in pages. Once you leave the respective page you simply unsubscribe the respective subscription - at least i never ever used observables in pages, only in services and passed them to subscription objects.

      I learned it this way:

      Service.ts

      Source Code

      1. queueData = new BehaviorSubject<any>([]);
      2. ...
      3. get queueInformation() {
      4. return this.queueData.asObservable();
      5. }
      And then below that function above so you can do this.queueData.next(data).

      So, in the page.ts, you do

      Source Code

      1. private queueInfo1: any;
      2. private queueSub: Subscription;
      3. ...
      4. ngOnInit() {
      5. this.queueSub = this.queueService.queueInfo.subscribe(result => {
      6. this.queueInfo1 = result;
      7. });
      8. }
      9. ngOnDestroy() {
      10. if(this.queueSub) this.queueSub.unsubscribe();
      11. }
      Display All

      At least i saw it in that way on many stackoverflow pages and tutorials i watched back then.
    • Cooperium wrote:

      Or do you put up simple empty variable and a subscription in the page.ts and a BehaviorObject in service.ts - so you update observables in services and not in pages. Once you leave the respective page you simply unsubscribe the respective subscription - at least i never ever used observables in pages, only in services and passed them to subscription objects.
      there how it works