The attack reduces blood loss and increases the attack severity.

Source: Internet
Author: User
/** Memorandum mode */# include <myhead. h> // Save the value class mysavevalue {public: mysavevalue (string user_name = "", int life_value = 100, int magic_point = 100, int rank_values = 1, int experience_value = 1000 ): _ user_name (user_name), _ life_value (life_value), _ magic_point (magic_point), _ rank_values (rank_values), _ experience_value (experience_value) {} mysavevalue & operator = (const mysavevalue & savevalue) {_ life_value = savevalue. _ life_value; _ magic_point = savevalue. _ magic_point; _ rank_values = savevalue. _ rank_values; _ experience_value = savevalue. _ experience_value; return * This;} public: String _ user_name; // User Name (or user ID (MD5 value) int _ life_value; // red blood int _ magic_point; // blue learning int _ rank_values; // level int _ experience_value; // experience value // other values}; // game role class role {public: Role (string user_name, int life_value, int magic_point, int rank_values, int experience_value): _ user_name (user_name), _ life_value (life_value), _ magic_point (magic_point), _ rank_values (rank_values ), _ savevalue save () // Save the current value {mysavevalue savevalue (_ user_name, _ life_value, _ magic_point, _ rank_values, _ experience_value); Return savevalue ;} void loadvalue (mysavevalue & savevalue) // The value before loading {_ life_value = savevalue. _ life_value; _ magic_point = savevalue. _ magic_point; _ rank_values = savevalue. _ rank_values; _ experience_value = savevalue. _ experience_value;} void show () {cout <"User:" <_ user_name.c_str () <", level:" <_ rank_values <", Red: "<_ life_value <", blue blood: "<_ magic_point <", current experience: "<_ experience_value <Endl;} void attack () // upgrade {_ magic_point-= 10; _ experience_value + = 250; If (_ experience_value = 1000)
{_ Rank_values + = 1; _ experience_value = 0 ;}} void being_attacked () // attacked {_ life_value-= 10;} PRIVATE: String _ user_name; int _ life_value; int _ magic_point; int _ rank_values; int _ experience_value;}; // saved progress Library Class lookaftersavevalue {public: lookaftersavevalue () {} void save (string name, mysavevalue savevalue) {_ mapsavevalue. insert (Map <string, mysavevalue >:: value_type (name, savevalue);} mysavevalue load (string name) {return _ mapsavevalue [name];} PRIVATE: Map <string, mysavevalue> _ mapsavevalue;}; // test case int main () {lookaftersavevalue; Role role ("role_wang", 100,100, 0, 0); role. show (); // The Initial Value lookaftersavevalue. save ("role_wang", role. save (); // Save the status role. attack (); role. show (); // lookaftersavevalue after attack. save ("role_wang", role. save (); // Save the status role. loadvalue (lookaftersavevalue. load ("role_wang"); // Load Status role. show (); // restore to 0 role. attack (); role. show (); // role after attack. attack (); role. show (); // role after attack. attack (); role. show (); // role after attack. attack (); role. show (); // role after attack. being_attacked (); role. show (); // lookaftersavevalue after being attacked. save ("role_wang", role. save (); // Save the status role. loadvalue (lookaftersavevalue. load ("role_wang"); // Load Status role. show (); // restore to status 1 getchar (); Return 0 ;}


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.