scieee AI-readable full text Open interactive document viewer

An online multiplayer sports management game using Laravel

López Balderas, Alejandro

Abstract

The following document presents the final project of the Bachelor's Degree in Video Game Design and Development taught at the Jaume I University of Castellón. The main idea of the project is the development of a sports management video game for the web: BBCoach. BBCoach is a 2D sports manager game developed in HTML, CSS, JavaScript and Laravel, a famous PHP language framework widely used in web programming.

Full text

1 An online multiplayer sports management game using Laravel Final Degree Work Bachelor's Degree in Video Game Design and Development Universitat Jaume I July 2019, Valencia Author: Alejandro López Balderas Supervisor: Antonio Morales Escrig 2 ACKNOWLEDGEMENTS My first words of thanks must be for Juan Carlos Amengual, surely, without his facility to see things and his support whenever I have needed it, I could not have planned my time to finally carry out this project. Also, to Antonio Morales, who has always been there when I needed him for any setback, doubt or question. And of course, to my family, you are everything. 3 ABSTRACT The following document presents the final project of the Bachelor's Degree in Video Game Design and Development taught at the Jaume I University of Castellón. The main idea of the project is the development of a sports management video game for the web: BBCoach. BBCoach is a 2D sports manager game developed in HTML, CSS, JavaScript and Laravel, a famous PHP language framework widely used in web programming. 4 CONTENTS Contents 1. Introduction 1.1. Work Motivation……………………………………………………………………………………………………………6 1.2. Objectives………………………………………………………………………………………………………………………7 1.3. Environment………………………………………………………………………………………………………………….7 1.3.1. Tools of Development…………………………………………………………………………………………….8 1.3.1.1. HTML/CSS……………………………………………………………………………………………………..8 1.3.1.2. JavaScript/Ajax……………………………………………………………………………………………..8 1.3.1.3. PHP/Laravel………………………………………………………………………………………………….8 1.3.1.4. MySQL/Heidi…………………………………………………………………………………………………8 1.3.1.5. XAMPP………………………………………………………………………………………………………….9 1.3.2. Why Laravel?..............................................................................................................9 1.4. Related Subjects…………………………………………………………………………………………………………….9 2. Planning 2.1. Initial Planning………………………………………………………………………………………………………………10 2.2. Final Planning……………………………………………………………………………………………………………….10 2.3. Resources evaluation……………………………………………………………………………………………………12 3. System analysis and design 3.1. Overview of the game and mechanics…………………………………………………………………………13 3.2. Characters……………………………………………………………………………………………………………………13 3.3. Requirement Analysis…………………………………………………………………………………………………..13 3.3.1. Functional Requirements……………………………………………………………………………………..13 3.3.2. Non-functional Requirements………………………………………………………………………………14 3.4. System Design………………………………………………………………………………………………………………14 3.4.1. Classes Diagram……………………………………………………………………………………………………15 3.4.2. Use case Diagram…………………………………………………………………………………………………17 3.5. Interface Design……………………………………………………………………………………………………………17 4. Work Development and Results 4.1. Work Development………………………………………………………………………………………………………22 4.1.1. Player creation and skill assignment……………………………………………………………………..23 4.1.2. Tactics…………………………………………………………………………………………………………………..23 4.1.3. Match simulator……………………………………………………………………………………………………24 4.1.4. Training………………………………………………………………………………………………………………..28 4.1.5. Calendar……………………………………………………………………………………………………………….29 4.2. Results, testing and validation………………………………………………………………………………………30 5. Conclusions and future work 5.1. Conclusions…………………………………………………………………………………………………………………31 5.2. Future work…………………………………………………………………………………………………………………31 Bibliography 5 LIST OF FIGURES Figure 1. Tools of development Figure 2. Gantt diagram installation Figure 3. Gantt diagram database plan Figure 4. Gantt diagram about functionality tasks Figure 5. Gantt diagram design Figure 6. Price of hosting Figure 7. Outline of a BBCoach season Figure 8. Model code Figure 9. Database schema Figure 10. Use case diagram Figure 11. FIFA MANAGER 14 Figure 12. Color pallete Figure 13. Dashboard page Figure 14. Calendar page Figure 15. Roster page Figure 16. Match page Figure 17. Tactics page Figure 18. Training page Figure 19. Configuration part of .env file Figure 20. Starting default Laravel Project Figure 21. Minutes distributor Figure 22. Team data 6 CHAPTER 1 INTRODUCTION Many studies show that, in relation to the loving and affective world, there is always that person in the world that you will love. Be handsome, ugly, tall, short, skinny, fat, friendly, gruff... there will always be someone who you would like. Well, in video games happens exactly the same, each of them has their own target, their own people to whom their personality and their way of living will make each of these games fit like a finger to them, and make them spend hours and hours in front of the screen. In my case, from a very young age I like everything around management, either sports, economic, political or military, which made me interested in this kind of video games. Games like Hattrick [ExtraLives AB, 1997], FIFA MANAGER Saga [EA Sports, 2005-2013], FarmVille [Zynga, 2009], Imperial Glory [Pyro Studios, 2005] or Pro Cycling Manager Saga [Cyanide Studio, 2005-2020] marked my childhood and influenced my creativity and my personality, to the extent that I am currently working into the creation and management of ERP (Enterprise Resource Planning) programs for big companies. Since I started the degree, I always had in mind to make some video game of this type, but naturally, I did not have the knowledge or experience necessary to carry it out. Now, thanks to my studies, I have learned to manage databases, to program in a web environment, to handle complex data structures or to design user interfaces, which has made me in the perfect situation to start a project for which I was destined. BBCoach unites this great hobby described above, with my other great passion, basketball. We are talking about a sports management game for a basketball club in which both, the leagues and the players involved in them, will be fictitious. A sort of virtual world in which each coach will have his management space in which he can take charge, among other things, of the training sessions and the way of playing of his team, or the minute charge of his players. 1.1 WORK MOTIVATION The reasons for carrying out this project are not only academic, in addition to what was mentioned in the previous point, I have carried out this project with the idea of commercializing it in the not too distant future, since there are very few games of this type with the features and design of BBCoach. From International Basket Manager, Pro Basket Manager 2019 or FIFA Manager, until Pro Cycling Manager, F1 Manager or Online Soccer Manager... likely 90% of this kind of games are developed around real players and clubs, having to pay licenses to leagues or federations for the use of their personal data. My work is based on another perspective, an idea of random no-real international players, that creates a really hard personal relationship between the user, their team and their players, because none of them is being used by any other player in the world at the same moment. 7 1.2 OBJECTIVES The main objectives of this project will be listed below, divided into technical and conceptual objectives. Technical Objectives - Run a project on a local environment for the development of a web project. - Get an online user login and register system. - Obtaining a rewarding user interaction system by introducing AJAX as the main programming tool. - Create a modern and dynamic user interface, with the latest UX / UI design innovations. Conceptual Objectives - Manage to convey to the user a sense of reality, making the players, the tactics, the games or the training sessions being based on situations that can usually occur in basketball. - Offer the player the possibility of controlling the game system of his team. - Make the user to want to see his team grow, by creating a training system that will improve physical and mental qualities. - Development of a multifactorial match simulator adapted to reality in terms of results and statistics. - Guarantee the user a unique and personal gameplay, in which the team and the players belong exclusively to him. 1.3 ENVIRONMENT 1.3.1 TOOLS OF DEVELOPMENT The main programs and languages (Figure 1) used during the development of the project are listed below, divided into types of tools: Figure 1. Tools of development - IDE: Sublime Text 3. [1] - Art: Photoshop [2], Adobe Comp. - Programming languages: HTML, CSS, Ajax, Javascript, JQuery, PHP (+Laravel Framework). - Database Management System: MySQL. - Web Server Solution Package: XAMPP. - Database administrator: Heidi. - Browsers: Google Chrome. 8 1.3.1.1. HTML / CSS [3] HTML and CSS are the basic languages to make any website. On the one hand, HTML is the language that gives a visual structure to the web pages. Headings, paragraphs, images, inputs of text or buttons are some of the possible contents that can be added to a website. On the other hand, CSS is used over HTML classes, defining their style properties. They are different, but as a web developer, you need to work both at the same time if you want a clean job. 1.3.1.2. JAVASCRIPT / JQUERY / AJAX [4] [5] [6] Alongside HTML and CSS, JavaScript is one of the core technologies of the World Wide Web. It enables interactive web pages and is an essential part of web applications. In this project, I mixed this language with his main multiplatform library, JQuery. It allows to simplify the way to interact with HTML documents, handle events or develop animations. In addition to all this, JQuery contributes to develop an interaction with AJAX, a web development technique to create interactive applications, which gives the user the ability to make changes on pages without reloading them, greatly improving the interactivity, speed and usability of websites. 1.3.1.3. PHP / LARAVEL [7] [8] PHP is a widely-used open source scripting language that is especially suited for web development and can be embedded into HTML. In this project, I used one of the most famous and used frameworks based on PHP, Laravel. Laravel is used to develop PHP in an elegant and simple way. It provides many positive functionalities: - Blade: Template system to create dynamic views in Laravel, very useful for not reusing code, as a developer can use the same view for some pages. Besides, naming and accessing data in blade views is easier than ordinary PHP. - Eloquent: Provides a beautiful and simple model system to interact with databases, which makes the code less stressful and easier to read. - Routing: One of the most important concepts in web developing is the routing system, that will allow the user decide which part of the page to visit, depending on the part of web clicked, or the URL typed. Laravel provides a very useful, clean and dynamic service of routes, giving developer the possibility to build simple or grouped routes, based on permissions. - Community and Documentation: It is known that Laravel has one of the best developer documentations in the framework of programming. Many people, including me, have learned Laravel based solely in these reports. In addition, its community is huge, allowing constant feedback and a faster and wider learning capacity. 1.3.1.4. MYSQL / HEIDI [9] I have used MySQL for the management of the game database. MySQL is an open source relational database management system (RDBMS) with a client-server model, a software used to create and manage databases based on a relational model. Also, I needed a program to be able to view and manage these databases in a more comfortable way, and that’s where Heidi comes. Heidi is a free and open-source administration tool for MySQL, that allows an easy and fast way to make 9 connections with MySQL servers, manage tables, rows and data from the same view or change the relational settings of our database. 1.3.1.5. XAMPP [10] And here is the tool that handles everything and makes our website work. XAMPP is an acronym, its letters mean: X: Cross-platform; A: Apache; M: MariaDB (MySQL); P: PHP; P: PERL. This free and open-source web server solution has allowed me to start a local Apache server with PHP and MySQL built in, to work locally on the project. 1.3.2 WHY LARAVEL? I decided to use this framework first of all because of its popularity, as its used in many companies for projects with large amounts of data. This made me interested both personally and professionally. Moreover, as I wanted to develop my idea over AJAX to improve the user experience with the game, not having to wait for the page being reloaded, Blade templates gave me the possibility of reusing views of same page and be able to load them by this programming method more easily. Finally, the simple treatment of databases would be particularly helpful for me, because I had to make a lot of calls to project tables. 1.4 RELATED SUBJECTS VJ1217 – Web game design and development. The concepts of MVC and development in JavaScript that I learned in the subject helped me. VJ1208 – Programming II. The base of everything, basic programming concepts necessary. VJ1215 – Algorithms and data structures. A very important part of my development as a programmer, I learned to develop complex and fast algorithms and to choose the correct data structures for it. VJ1209 – 2D Design. Concepts of web layout and use of Photoshop. VJ1220 – Databases. Another of the subjects that most helped me for the realization of the project. The creation and manipulation of databases is essential in my development. 16 Figure 9. Database Schema 17 3.4.2 USE CASE DIAGRAM The use case diagram (Figure 10) is described below, in which we find the two main actors in the development of the game, the user and the system. The system is included as an actor because it is programmed to perform certain functions by itself, at certain specific times. For example, when the time comes for a game, the system will know that the game has to be played, and the same will happen with training. Currently in this version of the project there are buttons to simulate all these situations. Figure 10. Use case Diagram 3.5 INTERFACE DESIGN As I mentioned in the introduction, I always loved management games, and the one that most impressed me with its design, both visually and interactively, was the FIFA MANAGER (Figure 11), with some great dashboards, in which practically does not miss any detail. I wanted my interface to have those two characteristics, to please the view of the player, and to offer him on a screen all the content about what he was seeing. But my game was not going to be an executable, it was going to work on a web page, so I had to adapt the menu and container layouts to web-oriented management layouts. I was very inspired by following different Instagram accounts (@uxuistack, @ui_lab or @farzan90.design, among others), and so I began to design my proposal. I wanted bright colors and a black background, very fashionable in management programs today. Finally (Figure 12), I mixed the classic black and white with a palette of yellow, blue and red that I found online. 18 Figure 11. FIFA MANAGER 14 Figure 12. Color Pallete The design of the game is based on a side menu through which to navigate between screens, having a control panel as the main page, in which the user can have an overview of the development of his team. The game screens are shown below, with a brief description of each one. HOME / DASHBOARD Figure 13. Dashboard page 19 Lace is the main concept that I have used both in this and the rest of the pages for the player’s good first impression. In this case (Figure 13), all the containers are equal in height and, except for the third, in width. This gives the user a little pleasure to see that everything fits, that everything is aligned, and that the distances between parts with the same characteristics are equal, it is a very important concept in the world of web layout. Another important part is the identification of the current screen, indicated in the upper right on each of the pages. TEAM / CALENDAR Figure 14. Calendar Page This page (Figure 14) has sought to highlight the listings above the standard container type with a light gray background. In addition, custom CSS scrolls have been designed with colors belonging to the project, such as the one seen in the list of upcoming matches. TEAM / ROSTER Figure 15. Roster Page 20 On this screen (Figure 15), some concepts that gratify the user experience are mixed. The AJAX programming technique allows us, by clicking on any of the rows of our players table, the container on the right loads the information of that player, changing the progress bars and the personal information of the player in less than 0.1 seconds. This, mixed with the contrast of colors and the use of icons, create an immersive page, versatile and easy to use. MATCH (Figure 16) Figure 16. Match Page TEAM / TACTICS Figure 17. Tactics Page Also custom-designed, we highlight on this page (Figure 17) the value markers, which save their values when you drop after also dragging through AJAX, which allows the player to change values of their tactics 21 or distribute the minutes of their players at a high speed, greater than if the page was reloaded each time. TEAM / TRAINING Figure 18. Training Page On this page (Figure 18) I wanted to play with the relationship between each workout and an icon. It is much more visual to be able to see the icon and know what you are training than to read it every time. Also, I have marked the improvements in green in the lower left container to give a positive reinforcement to the training. 22 CHAPTER 4 WORK DEVELOPMENT AND RESULTS 4.1 WORK DEVELOPMENT 4.1.1. INITIAL STATE The project started with the installation and creation of a Laravel project within our local server through Composer, an installer of PHP packages, among which is the framework that has been used. composer create-project --prefer-dist laravel / laravel blog This command, executed on the folder chosen for our development, created an MVC structure (Model View Controller) to work on, which we will explain after. Later, a MySQL database was created with Heidi and her credentials were configured. To finish, before I could run first test, I had to edit .env (Figure 19) file (simple configuration) created in the project, to connect with the local server (APP_URL) and with the created database (DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD). Figure 19. Configuration part of .env file Once this is done, accessing the IP address of our local server from the browser, you will find the views and functionalities that Laravel brings by default (Figure 20). And here the dance begins. Figure 20. Starting default Laravel project 23 4.1.1. PLAYER CREATION AND SKILL ASIGNMENT My idea from the beginning was to create a special bond between the user and his players, that he felt them own and real. To start, a random nationality is assigned to the player, within a list of 5 (Spanish, French, Italian, Turkish and German) and depending on it, applying this nationality to a PHP library for creating random people called faker (https://github.com/fzaninotto/Faker), the 'Player' object is created, and different attributes are randomly created over it. Thus, within the randomness of its creation, the skills and physical attributes of the players are gradually assigned, depending on each other, to make it as transparent and credible as possible. Next, I go on to detail the order developed when assigning physical features or abilities and some examples. The first thing to be assigned as I have said before is the nationality, from there the name and surname, in addition to the age, which is nearly (70%), thinking of a real professional basketball team, to a value between 22 and 32 years old, and to a lesser extent youth and maturity (20% from 18 to 21 years old and 10% from 33 to 37 years old). Then, position is given to player, based on his height, weight and abilities. To finish, experience, leadership and determination are generated, where age has a significant weight in the first two, being high for players over 30 years old, and normal until 26 years old. Younger players will have to play many games in order to increase these social skills. The relationship between the different positions and the skills in which they excel with respect to the rest is detailed below (Table 8). POSITION MAIN SKILL Point Guard 1-point shot, game vision, direction, ball control. Small Guard 1-point shot, 3-point shot, speed. Small Forward 3-point shot, jump. Power Forward Rebound, strength, footwork, jump. Center Rebound, strength, footwork. Table 8.Main skills by position 4.1.2. TACTICS This is the section that determines within the team how, who and how much they play. We can divide it into 3 parts: General tactics, starting-five and minutes distribution. General tactics control the three main aspects of a basketball game, the rhythm of the team, the type of attack and the type of defense. Each of them influences a circumstantial part of the development of the match, we will comment it on in the next point. The starting-five is done by position, and is usually made up of the best players on your team, who will get you started on the best match. Finally, we will explain in more detail the development in the project of the minute distributor (Figure 21), a fundamental part of the rotation of the players in the match. 24 Figure 21. Minutes distributor The only restriction in game is that each player has to play in his position during the match, and based on it, a tool (Figure 15) that distributes 40 minutes among the players of the same location has been developed. A player's minute marker stops at the maximum number of minutes he can play, depending on the time allotted to his other teammates on the field. In addition, for each of these positions, the time remaining to be allocated will be displayed. 4.1.3 MATCH SIMULATOR This is the basis on which much of the project is based, the development that I'm most proud of. To develop this part, I have created a set of functions that conceptually could be summarized in: The clock, the events, and the central data structure of the game. - The clock or game time. 10 minutes divided into four quarters, 40 in total. From this standard, the events continue, until the time of each quarter and the game runs out. When an event ends, the attacking and defending teams may or may not exchange, depending on the type of event itself. - Events. Each of the events that take place about the game is made up of a specific time and type. o Event time: random element that will depend on the game rhythm chosen by the attacking team. Attacks at normal speed always have a 50% percentage to occur, and the other 50% are divided into fast and slow attacks. Thus, if the tempo tactic is somewhere in between, there will be a 25% chance of both a fast attack and a slow attack. On the contrary, if the tempo tactic is at 75%, there will be a 37.5% 25 probability that the attack will be fast, and 12.5% that it will be slow. The times of each type of attack have been chosen based on real basketball situations. ▪ Fast attack: 7 to 10 seconds. ▪ Normal attack: 10 to 16 seconds. ▪ Slow attack: from 16 to 24 seconds. o Types of events: In addition to a certain duration, an event has a certain action, and here many factors, both individual and collective, compete to win the raffle. Next table (Table 9) summarizes the types of events, and the factors that influence each of them. TYPE OF EVENT FACTORS THAT INFLUENCE Attack 2Pointer 2-point*3, jump, ball control, endurance*2 Attack 3Pointer 3-point*3 (or *4 if skill is higher than 80), jump, ball control, endurance Defense 2Pointer Individual Defense*3, jump, Team Defense, endurance*2 Defense 3Pointer Individual Defense*3, jump, Team Defense, endurance*2 Turnover Ball control, Pass, Experience, Individual Defense Assist Random, but higher percentage on Guards and Small Guards. Steal Ball control, Pass, Experience, Individual Defense First Free Throw in 1-point Second Free Throw in 1-point Third Free Throw in 1-point First Free Throw out 1-point Second Free Throw out 1-point Third Free Throw out 1-point Offensive Foul Random, 10% percentage inside fouls. Personal Foul Individual Defense, Experience Out of Bounds Ball control, Pass, Experience, Individual Defense Substitution Minutes Defensive Rebound Random, but higher percentage on Centers and Power Forwards. Offensive Rebound Random, but higher percentage on Centers and Power Forwards. Time-out 5% Random. Table 9. Relationship of events and factors To finish, each one of these events, as they are carried out, keep saving and updating different variables located in a central data structure, which will be explained in the next point. We can see just below, as an example, next table with the statistical values that are updated for each event. TYPE OF EVENT UPDATED Attack 2Pointer 2-point made, 2-point attempts Attack 3Pointer 3-point made, 3-point attempts Defense 2Pointer 2-point attempts Defense 3Pointer 3-point attempts Turnover Turnovers Assist Assists Steal Steals First Free Throw in 1-point made, 1-point attempts Second Free Throw in 1-point made, 1-point attempts Third Free Throw in 1-point made, 1-point attempts First Free Throw out 1-point attempts Second Free Throw out 1-point attempts 32 BIBLIOGRAPHY LINKS [1] Sublime Text 3: https://www.sublimetext.com/ [2] Photoshop: https://www.adobe.com/es/products/photoshop.html [3] HTML/CSS: https://www.w3.org/standards/webdesign/htmlcss [4] JavaScript: https://developer.mozilla.org/es/docs/Web/JavaScript [5] JQuery: https://jquery.com/ [6] AJAX: https://www.w3schools.com/xml/ajax_intro.asp [7] PHP: https://www.php.net/manual/en/intro-whatis.php [8] Laravel: https://laravel.com/docs/7.x [9] Heidi: https://www.heidisql.com/ [10] XAMPP: https://www.apachefriends.org/es/index.html [11] Stratos: https://www.stratos-ad.com/