Introduction to cloud development platform forks the "Life Restart Simulator" to the cloud-developed warehouse. Users only need to fork directly to their own warehouse to perform quick magic changes and one-click deployment on the cloud development platform. By deciding your own domain name, you can let the friends come to experience your magical innovation.
Life cannot be repeated, the game can be restarted!
The life reopening simulator is inexplicably hot, this is a pure text MUD game. Players can start the game by choosing 3 from 10 unique talents, and assigning points to their 4 attributes (face value, intelligence, physique, and family status) to restart your life. You can’t predict what kind of experience you will have. For example, when you are 2 years old and die without eating enough, the government requires school to end at 5 o’clock, family difficulties, not having enough food, going to jail, having a girlfriend, and having a boy for a while. Friends, wait, there are many very powerful hidden endings in this game!
The whole picture of this game is the whole process, such as playing PPT, generally from birth to death, without art, sound effects, or even advertising. But its magical random text entries mix and match the ordinary and plain daily life, and occasionally there will be weird developments. It makes me want to explore the boundaries of life, repeatedly reopen, repeatedly filter talents and configure attributes, and always want to experience it. The same life reincarnated hundreds of times accidentally. I became addicted as soon as I played. I reopened my life almost 300 times. I couldn't escape the ordinary fate. I still didn't experience the open life. Come on, come on, come on, you can have the immortal version, the immortal version, and the sound effect version.
The cloud development platform forks the original project to the cloud development warehouse. Users only need to directly fork to their own warehouse and then they can perform quick magic changes and one-click deployment on the cloud development platform, and bind their own domain names to enable small partners Let's feel your magic transformation creativity together.
The Realization Logic Analysis of Life Restart Simulator
There are no more than 10 js files in the game's repo, and no complicated libraries are used. It is just a simple front end with jQuery and css. The only more complicated part is the game logic processing.
First of all, game data, such as talents and events, are stored in the data directory : there are xlsx and json files related to game data, such as events that may occur at each age, conditions for each event, talents, etc. The author also wrote a script file utils/xlsxTransform.js to convert xlsx files into json for easy reading.
Studying this table, we can find that there are several basic attributes
- CHR (Charm): face value
- INT (Intelligence): Intelligence
- STR(Strong): physique
- MNY(Money): Family
- SPR (Spirit): Happiness
- LIF(Life): Life
The occurrence of the incident may bring about changes in appearance, intelligence, physique, and family circumstances.
- life change of 161445a476e6fd is only "-1" . Including "you are dead" and "ascending to heaven" two situations. So friends who have succeeded in cultivating immortals should not be too proud. You think you are in the immortal class, maybe it is the ripe fruit that was picked by the gods?
- " can only be randomized to when there is an event" and " when there is an event" created a rural line, an urban line, and a Chinese-American line with different fate. Talent (TLT, talent) also has an impact on the occurrence of events. For example, a tall building in a city must be born in a city.
- After an event occurs, it may go to different branches according to the pre-event and character attributes. For example, the "You were molested by a teacher" event will go to "You have reported to the police and the teacher was detained" when the character INT>7. On the contrary, "You are gradually depressed, but you dare not talk to others."
Secondly, the main code of the game is under src directory :
You can start src/index.js
, this file does two things:
- Read the json game data under data just mentioned and bind it as a global variable; bind a global banner handler.
- Initialize the app.
import App from '../src/app.js';
window.json = async fileName => await (await fetch(`../data/${fileName}.json`)).json();
// Pssst, I've created a github package - https://github.com/brookesb91/dismissible
window.hideBanners = (e) => {
document
.querySelectorAll(".banner.visible")
.forEach((b) => b.classList.remove("visible"));
};
const app = new App();
app.initial();
Then you can read src/app.js
, which is the main front-end jQuery
part, responsible for generating views and binding functions, basically most of the front-end logic is here. For example, the following code:
const indexPage = $(`
<div id="main">
<div id="cnt" class="head">已重开1次</div>
<button id="rank">排行榜</button>
<button id="themeToggleBtn">黑</button>
<div id="title">
人生重开模拟器<br>
<div >这垃圾人生一秒也不想呆了</div>
</div>
<button id="restart" class="mainbtn"><span class="iconfont"></span>立即重开</button>
</div>
`);
indexPage
.find('#restart')
.click(()=>this.switch('talent'));
This code is to first write a html component indexPage
, and then find a restart
, and bind a function ()=>this.switch('talent')
. this.switch
should be used to switch between different screen
. The logic here is "after clicking the reopen button, switch to the talent selection page".
Then the src
are related to game logic:
event.js
is responsible for the logic related to random events,
property.js
is responsible for the logic of role attributes,
talent.js
is responsible for talent-related logic,
life.js
is the logic of life advancement.
src/function
under some helper function
, including for events condition
of parsing
, summarizing life.
Magic Revised Life Reopening Simulator One-click Hosting
1. Environmental preparation
- Log in to the cloud development platform. Open the URL https://workbench.aliyun.com/ , log in with an Cloud account, 161445a476ed83 follow the prompts to create a team , click to agree to the agreement . Users who do not have an Alibaba Cloud account can log in after registering on the login page. In order to ensure the best user experience, please use the Chrome browser.
- Create the code warehouse required for the project. Visit https://github.com/AliyunWorkbench/lifeRestart . After clicking fork, log in with your github account and fork the code repository of this project directly to your GitHub account. The code in this repository is consistent with the content of the default template generated by hexo init.
2. Create a life simulator application
- Create a front-end application. Open the quick start https://workbench.aliyun.com/page/quickstart and click the Create "Front-end Application" button.
- Cloud resource access authorization. If you have not used the cloud development platform before, there will be an option for cloud resource authorization management, scroll down until the words agree to authorization, click "Agree to Authorize" and the authorization is successful, click to enter "Next".
- Bind Github account. After the authorization is completed, select the source repository as Github, follow the prompts to click to bind, bind the GitHub account, log in and click Authorize Aliyunworkben to allow the cloud development platform to build and publish your GitHub code as an accessible website.
- Choose a good code repository for fork. code warehouse and trunk branch in the first step, and click Next. The main branch generally refers to the master or main branch of the code.
- Fill in the basic information to complete the creation. Fill in the basic information and click "Finish". After success, enter the application details and deployment interface.
3. Configure and launch the application in the daily environment
- Obtain the AK/SK of the Alibaba Cloud account. Click https://ram.console.aliyun.com/manage/ak to create an Accesskey. After success, AccesskeyID (AK) and AccessKey Secret (SK) will be generated
- Deployment configuration. After the application is created, it will jump to the application details page, click on the deployment configuration in the line of the daily environment, and then there is a configuration description in the pop-up window, scroll down the page to see the button to configure.
- Configure Github. Click the "Go to Configuration" button above to go to Github, click new reposority secret, and create two secrets with AK and SK as the Name respectively. The specific Value uses the values of AccessKey ID and AccessKey Secret obtained above. You can see it after creation. There are two secrets, AK and SK.
- One-click deployment. After the configuration is complete, click the "Deploy" button in the daily environment to perform one-click deployment
4. Visit after successful deployment
- After the deployment is successful, click " deployment configuration " again, and click " test domain name " on the pop-up window to access your application. The temporary domain name is valid for 30 minutes. Please pay attention to the expiration time of the test domain name. Refresh after expiration and you can continue to use it. The link supports sharing with friends to visit. If the magic change has been modified and you want to go online for a long time for everyone to play with, you can bind it to your personal domain name by following the steps below.
- Bind personal domain names. Add your own custom domain name, in the online environment "Deployment Configuration" "Custom Domain Name" , add the domain name under your own name, and click Deploy again. Then follow the prompts and transfer the domain name CNAME under your name to the specified OSS domain name, then you can use your own domain name and continue to access the application.
- Use CDN to accelerate domain name access and save traffic costs (optional). When the website traffic is huge, you can click "How to configure CDN acceleration" in "Deployment Configuration" to bind your domain name with CDN acceleration to speed up website access and save traffic costs.
- Visit the online deployment website. After the CNAME takes effect, we can enter the domain name just bound in the browser to access the applications deployed to the online environment. So far, how to deploy an application to the online environment, how to bind your own domain name to access an online application is complete, quickly deploy your own application to the online environment, and play with your own domain name;)
Game life, live in the moment
Online address: http://demo-liferestart.workbenchapi.com/
If you think of it as a game, keep reopening just to try to play as many branch endings as possible;
If you think of it as life, keep reopening it is to experience a different life as much as possible;
After watching the recently released "Out of Control Player", I suddenly felt:
Isn't the NPC who repeats life in the game again and again tired of the same boring life, eager to experience a different life?
But after another thought, in fact, each of us is not an NPC in other people's world?
So, don't worry, live the present, live yourself well, that's enough.
Of course, in your spare time, you can also restart the life simulator to feel the open life and the brain of the game!
Using a cloud development platform for the first time?
- Experience the most advanced serverless cloud development model for free, and receive a 10 yuan Alibaba Cloud no-threshold voucher refueling package.
- Website: https://workbench.aliyun.com/activities/coupon
Thanks: The article refers to the views of Sisyphus, Netizens and other netizens, thank you!
Copyright Notice: content of this article is contributed spontaneously by Alibaba Cloud real-name registered users. The copyright belongs to the original author. The Alibaba Cloud Developer Community does not own its copyright and does not assume corresponding legal responsibilities. For specific rules, please refer to the "Alibaba Cloud Developer Community User Service Agreement" and the "Alibaba Cloud Developer Community Intellectual Property Protection Guidelines". If you find suspected plagiarism in this community, fill in the infringement complaint form to report it. Once verified, the community will immediately delete the suspected infringing content.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。