File indexing completed on 2024-05-12 05:39:29

0001 /***************************************************************************
0002  * Copyright (C) 2014 by Renaud Guezennec                                   *
0003  * https://rolisteam.org/contact                      *
0004  *                                                                          *
0005  *  This file is part of DiceParser                                         *
0006  *                                                                          *
0007  * DiceParser is free software; you can redistribute it and/or modify       *
0008  * it under the terms of the GNU General Public License as published by     *
0009  * the Free Software Foundation; either version 2 of the License, or        *
0010  * (at your option) any later version.                                      *
0011  *                                                                          *
0012  * This program is distributed in the hope that it will be useful,          *
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of           *
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the             *
0015  * GNU General Public License for more details.                             *
0016  *                                                                          *
0017  * You should have received a copy of the GNU General Public License        *
0018  * along with this program; if not, write to the                            *
0019  * Free Software Foundation, Inc.,                                          *
0020  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.                 *
0021  ***************************************************************************/
0022 #include "scalarresult.h"
0023 
0024 ScalarResult::ScalarResult()
0025 {
0026     m_resultTypes= static_cast<int>(Dice::RESULT_TYPE::SCALAR);
0027 }
0028 
0029 void ScalarResult::setValue(qreal i)
0030 {
0031     m_value= i;
0032 }
0033 QVariant ScalarResult::getResult(Dice::RESULT_TYPE type)
0034 {
0035     if(Dice::RESULT_TYPE::SCALAR == type)
0036     {
0037         return m_value;
0038     }
0039     else
0040         return {};
0041 }
0042 Result* ScalarResult::getCopy() const
0043 {
0044     auto copy= new ScalarResult();
0045     copy->setValue(m_value);
0046     return copy;
0047 }
0048 QString ScalarResult::toString(bool wl)
0049 {
0050     if(wl)
0051     {
0052         return QString("%2 [label=\"ScalarResult %1\"]").arg(m_value).arg(m_id);
0053     }
0054     else
0055     {
0056         return m_id;
0057     }
0058 }